Skip to Content
author's profile photo Former Member
Former Member

Not able to send Internal or SAP Office mail with attachment

Hi,

I am not able to send internal mail or SAP office mail with attachement through 'SO_NEW_DOCUMENT_SEND_API1' FM.

Can any suggest me how i send internal mail through this fm or other fm .Provide code if possible.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on May 28, 2008 at 07:19 AM

    Hi,

    ABAP Program (function module) to send SAPOffice mail

    SAP supplies a function module 'SO_OBJECT_SEND' to allow you send SAPOffice mails from within your ABAP programs. However, using that function module is complex and takes a lot of time to understand the usage of it.

    The following function module is just a wrap around for SO_OBJECT_SEND and takes away much of the complexity out of the process. This function module not only sends a SAPOffice mail but also points to the current spool list. As you can see, many of the parameters have their defaults.

    Parameter Descriptions

    Either RECEPIENT or DLI must be specified. If the mail should be sent to several people, create a distribution list and supply its name for DLI.

    Internal table TEXT should contain the body of the mail message.

    While this function module can be used as it is, it is just an example. SO_OBJECT_SEND is very comprehensive and many of the features are omitted from this example. You are encouraged to examine SO_OBJECT_SEND, see all the available features, and change this function module to suit your requirements.

    -


    -


    FUNCTION Z_SEND_MAIL_FOR_SPOOLLIST.

    *"----


    ""Local interface:

    *" IMPORTING

    *" VALUE(SPOOLNUMBER) LIKE SY-SPONO DEFAULT SY-SPONO

    *" VALUE(MAILNAME) LIKE SOOD1-OBJNAM DEFAULT 'NOTE'

    *" VALUE(SUBJECT) LIKE SOOD1-OBJDES

    *" VALUE(RECEPIENT) LIKE SY-UNAME OPTIONAL

    *" VALUE(DLI) LIKE SOOS1-DLINAM OPTIONAL

    *" TABLES

    *" TEXT STRUCTURE SOLI OPTIONAL

    *" EXCEPTIONS

    *" ERROR

    *"----


    DATA: OBJECT_HD_CHANGE LIKE SOOD1 OCCURS 0 WITH HEADER LINE,

    OBJPARA LIKE SELC OCCURS 0 WITH HEADER LINE,

    RECEIVERS LIKE SOOS1 OCCURS 0 WITH HEADER LINE.

    OBJECT_HD_CHANGE-OBJLA = SY-LANGU.

    OBJECT_HD_CHANGE-OBJNAM = MAILNAME.

    OBJECT_HD_CHANGE-OBJDES = SUBJECT.

    OBJECT_HD_CHANGE-OBJSNS = 'F'.

    OBJECT_HD_CHANGE-VMTYP = 'T'.

    OBJECT_HD_CHANGE-SKIPS = 'X'.

    OBJECT_HD_CHANGE-ACNAM = 'SP01'.

    OBJECT_HD_CHANGE-OBJCP = 'X'.

    RECEIVERS-RCDAT = SY-DATUM.

    RECEIVERS-RCTIM = SY-UZEIT.

    IF DLI IS INITIAL.

    RECEIVERS-RECNAM = RECEPIENT.

    RECEIVERS-RTUNAM = RECEPIENT.

    ELSE.

    RECEIVERS-RECNAM = DLI.

    RECEIVERS-ADR_NAME = DLI.

    RECEIVERS-RECESC = 'C'.

    ENDIF.

    RECEIVERS-SNDEX = 'X'. " Express-Mail

    APPEND RECEIVERS.

    OBJPARA-NAME = 'SPI'.

    OBJPARA-LOW = SPOOLNUMBER.

    APPEND OBJPARA.

    CALL FUNCTION 'SO_OBJECT_SEND'

    EXPORTING

    OBJECT_HD_CHANGE = OBJECT_HD_CHANGE

    OBJECT_TYPE = 'RAW'

    OWNER = SY-UNAME

    TABLES

    OBJCONT = TEXT

    OBJPARA = OBJPARA

    RECEIVERS = RECEIVERS

    EXCEPTIONS

    OTHERS = 01.

    IF SY-SUBRC NE 0.

    RAISE ERROR.

    ENDIF.

    ENDFUNCTION.

    Regards,

    Jagadish

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 28, 2008 at 08:31 AM

    Hi Gurprit,

    Check this code. This will help you send mail with attachments also.

    ***************************************************************

    zdp_solisti1 is a structure having fields naming LINE of type LCHR and its length being 2500.

    *******Email declarations

    data : gv_delimit TYPE c,

    lv_lncnt1(5) TYPE c,

    tempread(10) TYPE c VALUE 0,

    objpack TYPE sopcklsti1 OCCURS 0 WITH HEADER LINE,

    objhead TYPE zdp_solisti1 OCCURS 1 WITH HEADER LINE,

    objbin TYPE soli OCCURS 0 WITH HEADER LINE,

    objtxt TYPE zdp_solisti1 OCCURS 0 WITH HEADER LINE,

    reclist TYPE somlreci1 OCCURS 0 WITH HEADER LINE,

    doc_chng LIKE sodocchgi1,

    tab_lines LIKE sy-tabix.

    CLEAR GV_DELIMIT.

    GV_DELIMIT = CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

    TEMPREAD = LV_LNCNT1.

    REFRESH OBJTXT.

    CONCATENATE 'The no. of error records are : ' TEMPREAD

    INTO OBJTXT-LINE.

    APPEND OBJTXT.

    CLEAR OBJPACK. REFRESH OBJPACK.

    CONCATENATE C_CODE

    C_CMMT

    C_COMMENT1

    INTO OBJTXT-LINE SEPARATED BY GV_DELIMIT.

    APPEND OBJTXT.

    LOOP AT IT_DATA INTO WA_DATA.

    CONCATENATE WA_DATA-ZCODE

    WA_DATA-ZCOMMENT

    WA_DATA-ZREASON

    INTO OBJTXT-LINE SEPARATED BY GV_DELIMIT.

    APPEND OBJTXT.

    ENDLOOP.

    CLEAR GV_DELIMIT.

    CLEAR OBJPACK. REFRESH OBJPACK.

    CLEAR DOC_CHNG.

    TAB_LINES = 0.

    OBJHEAD = REJFILE. APPEND OBJHEAD.

    DESCRIBE TABLE OBJTXT LINES TAB_LINES.

    READ TABLE OBJTXT INDEX TAB_LINES.

    DOC_CHNG-OBJ_NAME = REJFILE.

    MOVE TEXT-006 TO

    DOC_CHNG-OBJ_DESCR.

    DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).

    CLEAR OBJPACK-TRANSF_BIN.

    OBJPACK-HEAD_START = 1.

    OBJPACK-HEAD_NUM = 0.

    OBJPACK-BODY_START = 1.

    OBJPACK-BODY_NUM = 1. " 3.

    OBJPACK-DOC_TYPE = 'RAW'.

    APPEND OBJPACK.

    FOR ASCII TO BINARY OBJECT FUNCTION

    TOTLINEXFER = 0.

    TOTXFER = 0.

    BINMAXLEN = 255.

    REFRESH OBJBIN.

    LV_CR = CL_ABAP_CHAR_UTILITIES=>CR_LF.

    TGTMAXLEN = BINMAXLEN.

    TGTLEN = 0.

    LOOP AT OBJTXT FROM 2.

    IF NOT OBJTXT-LINE CP 'The no. of records are '." AND

    CONCATENATE OBJTXT-LINE LV_CR INTO BUFFER.

    SRCOBJLEN = STRLEN( BUFFER ).

    SRCOBJPTR = 0.

    WHILE SRCOBJLEN > 0 .

    XFERLEN = TGTMAXLEN - TGTLEN.

    IF XFERLEN > SRCOBJLEN.

    XFERLEN = SRCOBJLEN.

    MOVE BUFFERSRCOBJPTR TO OBJBIN-LINETGTLEN.

    TGTLEN = TGTLEN + SRCOBJLEN.

    SRCOBJLEN = 0.

    CLEAR BUFFER.

    ELSE.

    MOVE BUFFER+SRCOBJPTR(XFERLEN) TO

    OBJBIN-LINE+TGTLEN(XFERLEN).

    APPEND OBJBIN.

    CLEAR OBJBIN-LINE.

    TGTLEN = 0.

    SRCOBJLEN = SRCOBJLEN - XFERLEN.

    SRCOBJPTR = SRCOBJPTR + XFERLEN.

    TOTLINEXFER = TOTLINEXFER + 1.

    ENDIF.

    TOTXFER = TOTXFER + XFERLEN.

    ENDWHILE.

    ENDIF.

    ENDLOOP.

    IF TGTLEN > 0.

    APPEND OBJBIN.

    TOTLINEXFER = TOTLINEXFER + 1.

    ENDIF.

    CLEAR OBJPACK-TRANSF_BIN.

    OBJPACK-TRANSF_BIN = 'X'.

    OBJPACK-HEAD_START = 1.

    OBJPACK-HEAD_NUM = 0.

    OBJPACK-BODY_START = 1.

    OBJPACK-BODY_NUM = TOTLINEXFER.

    OBJPACK-DOC_TYPE = 'XLS'.

    OBJPACK-OBJ_NAME = REJFILE.

    OBJPACK-OBJ_DESCR = 'Rejected Entries File'.

    OBJPACK-DOC_SIZE = TOTXFER.

    APPEND OBJPACK.

    REFRESH RECLIST.

    MAIL1 = 'xxxxxxxx' " Email Address

    RECLIST-RECEIVER = MAIL1.

    RECLIST-REC_TYPE = 'U'.

    APPEND RECLIST.

    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

    EXPORTING

    DOCUMENT_DATA = DOC_CHNG

    PUT_IN_OUTBOX = 'X'

    COMMIT_WORK = 'X'

    TABLES

    PACKING_LIST = OBJPACK

    OBJECT_HEADER = OBJHEAD

    CONTENTS_BIN = OBJBIN

    CONTENTS_TXT = OBJTXT

    RECEIVERS = RECLIST.

    IF SY-SUBRC 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    ***************************************************************

    Hope this is helpful to you. If you need further information, revert back.

    Reward all the helpful answers.

    Regards

    Nagaraj T

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.