Skip to Content
avatar image
Former Member

sending email

Hi all,

iam having a internal table with user id 's and other data. I need to send email to every user with below mentioned body

infotype name old value new value

006 5 6

etc

regrads

venkaty

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Oct 16, 2008 at 09:30 AM

    Hi,

    you can use FM 'SO_DOCUMENT_SEND_API1' to send mail. fill the body of the mail to the "contents_txt" parameter in the tables tab, as you have an internal table with the neccesary information. fill the commit_work parameter with value 'X' otherwise it doesn't send the mail.

    regards,

    Murat Kaya

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 16, 2008 at 10:51 AM

    hi ,

    code for sending the mail..

    DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE,

    OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE,

    OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

    OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE,

    RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.

    DATA: DOC_CHNG LIKE SODOCCHGI1,

    TAB_LINES LIKE SY-TABIX.

    • Data for the status output after sending

    DATA: SENT_TO_ALL LIKE SONV-FLAG.

    CLEAR: IT_RECLIST, IT_RECLIST[],

    IT_OBJTXT , IT_OBJTXT[],

    IT_OBJPACK, IT_OBJPACK[],

    IT_OBJBIN , IT_OBJBIN[],X_DOC_CHNG.

    LOOP AT IT_HTML.

    OBJBIN-LINE = IT_HTML-LINE.

    APPEND OBJBIN.

    CLEAR OBJBIN.

    ENDLOOP.

    • Create the document which is to be sent

    DOC_CHNG-OBJ_NAME = 'List'(012).

    DOC_CHNG-OBJ_DESCR = 'Mail'(013).

    • Heading

    OBJTXT-LINE = 'Mail with pdf attachment'(014).

    APPEND OBJTXT.

    CLEAR OBJTXT.

    • Size

    DESCRIBE TABLE OBJTXT LINES TAB_LINES.

    READ TABLE OBJTXT INDEX TAB_LINES.

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

    • Fill the fields of the packing_list for the main document:

    CLEAR OBJPACK-TRANSF_BIN.

    • The document needs no header (head_num = 0)

    OBJPACK-HEAD_START = 1.

    OBJPACK-HEAD_NUM = 0.

    • Body

    OBJPACK-BODY_START = 1.

    OBJPACK-BODY_NUM = TAB_LINES.

    OBJPACK-DOC_TYPE = 'RAW'(015).

    APPEND OBJPACK.

    • Create the attachment (the list itself)

    DESCRIBE TABLE OBJBIN LINES TAB_LINES.

    • Fill the fields of the packing_list for the attachment:

    OBJPACK-TRANSF_BIN = 'X'.

    • Header

    OBJPACK-HEAD_START = 1.

    OBJPACK-HEAD_NUM = 0.

    • Body

    OBJPACK-BODY_START = 1.

    OBJPACK-BODY_NUM = TAB_LINES.

    OBJPACK-DOC_TYPE = 'PDF'(016).

    OBJPACK-OBJ_NAME = 'Attachment'(017).

    OBJPACK-OBJ_DESCR = 'Mail with pdf Attachment'(018).

    OBJPACK-DOC_SIZE = TAB_LINES * 255.

    APPEND OBJPACK.

    *-Fill the mail recipient list

    LOOP AT MAIL.

    RECLIST-RECEIVER = MAIL-LOW.

    RECLIST-REC_TYPE = C_U.

    APPEND RECLIST.

    CLEAR: RECLIST,

    MAIL.

    ENDLOOP.

    *-Send the document by calling the SAPoffice API1 module for sending

    *-documents with attachments

    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

    EXPORTING

    DOCUMENT_DATA = DOC_CHNG

    PUT_IN_OUTBOX = C_X

    COMMIT_WORK = C_X

    IMPORTING

    SENT_TO_ALL = SENT_TO_ALL

    TABLES

    PACKING_LIST = OBJPACK

    OBJECT_HEADER = OBJHEAD

    CONTENTS_BIN = OBJBIN

    CONTENTS_TXT = OBJTXT

    RECEIVERS = RECLIST

    EXCEPTIONS

    TOO_MANY_RECEIVERS = 1

    DOCUMENT_NOT_SENT = 2

    OPERATION_NO_AUTHORIZATION = 4

    OTHERS = 99.

    CASE SY-SUBRC .

    WHEN 0.

    MESSAGE I000 WITH 'Mail has been sent successfully'(006).

    WHEN OTHERS.

    MESSAGE E000 WITH 'Problem in sending the mail'(023).

    ENDCASE.

    ENDFORM. " send_mail

    Add comment
    10|10000 characters needed characters exceeded