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

E-Mail as text attachment

Hi,

I want to email as a TEXT file attachment. I tried using SO_DOCUMENT_SEND_API1 this is working good . using this fm i can able to send text file as an attachment but the data format is not correct.iam getting the attachment in this format.

<b> PAX# TITLE/NAME AGE TELEPHONE

1 MRS ASDCVCC,SDF 6104442324

2 MR ASDFFDDS,AESFEE 6104442324

3 MR ASDFFDDS,AESFEE 6104442324

4 MISS BARR,SARA ANN 15

5 MRS BARR,VALERIE DEE

6 MR BARR III,CHARLES THOMAS 6107571103

7 MR BARRAUD,ERNEST </b>

Thanks

Vikranth Khimavath

Message was edited by:

Khimavath Vikranth

Message was edited by:

Khimavath Vikranth

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 31, 2007 at 04:41 PM

    Hi,

    Check this code:

    ***Sending mail to the receipients

    if not it_final[] is initial.

    • Populate table with detaisl to be entered into .xls file

    PERFORM BUILD_XLS_DATA_TABLE.

    PERFORM POPULATE_EMAIL_MESSAGE_BODY.

    • Send file by email as .xls speadsheet

    PERFORM SEND_FILE_AS_EMAIL_ATTACHMENT

    TABLES IT_MESSAGE

    IT_ATTACH

    USING P_EMAIL

    'Sales Register Report - Set Top Box / Accessories'

    'XLS'

    'SSTB'

    ' '

    ' '

    ' '

    CHANGING GD_ERROR

    GD_RECIEVER.

    • Instructs mail send program for SAPCONNECT to send email(rsconn01)

    PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.

    endif.

    &----


    *& Form BUILD_XLS_DATA_TABLE

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM BUILD_XLS_DATA_TABLE .

    data: wa_itab like it_final.

    CONSTANTS:

    CON_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,

    CON_CRET TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF.

    CONCATENATE 'Business Place' 'Region Code' 'Region' 'Branch Code'

    'Branch' 'Material Desc' 'Area off Code'

    'Area Name' 'Zone code' 'Zone Name' 'Cust No' 'Cust Name'

    'Bill Doc No' 'Bill Date' 'Base Val' 'Total Val' 'Quantity'

    INTO IT_ATTACH SEPARATED BY CON_TAB.

    CONCATENATE CON_CRET IT_ATTACH INTO IT_ATTACH.

    APPEND IT_ATTACH.

    LOOP AT IT_FINAL INTO WA_ITAB.

    CONCATENATE WA_ITAB-BUSINESS_PLACE

    WA_ITAB-KVGR1

    WA_ITAB-REGION

    WA_ITAB-VKBUR

    WA_ITAB-SALES_OFF

    WA_ITAB-ARKTX

    WA_ITAB-vkgrp

    WA_ITAB-sales_grp

    WA_ITAB-bzirk

    WA_ITAB-zone

    WA_ITAB-kunnr

    WA_ITAB-name

    WA_ITAB-vbeln

    WA_ITAB-fkdat

    WA_ITAB-base_value

    WA_ITAB-total_value

    WA_ITAB-fkimg

    INTO IT_ATTACH SEPARATED BY CON_TAB.

    CONCATENATE CON_CRET IT_ATTACH INTO IT_ATTACH.

    APPEND IT_ATTACH.

    ENDLOOP.

    ENDFORM. " BUILD_XLS_DATA_TABLE

    &----


    *& Form POPULATE_EMAIL_MESSAGE_BODY

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM POPULATE_EMAIL_MESSAGE_BODY .

    REFRESH IT_MESSAGE.

    CONCATENATE SY-DATUM6(2) '/' SY-DATUM4(2) '/' SY-DATUM+0(4) INTO G_DATE.

    IT_MESSAGE = 'Please find attached excel sheet.'.

    APPEND IT_MESSAGE.

    IT_MESSAGE = 'Sales Register Report - Set Top Box / Accessories'.

    APPEND IT_MESSAGE.

    Concatenate 'Report generated date' ':' G_Date '.' into IT_MESSAGE.

    APPEND IT_MESSAGE.

    clear it_message.

    append it_message.

    IT_MESSAGE = 'This is an autogenerated mail, please do not reply'.

    APPEND IT_MESSAGE.

    ENDFORM. " POPULATE_EMAIL_MESSAGE_BODY

    &----


    *& Form SEND_FILE_AS_EMAIL_ATTACHMENT

    &----


    • Send email

    ----


    FORM SEND_FILE_AS_EMAIL_ATTACHMENT TABLES PIT_MESSAGE

    PIT_ATTACH

    USING P_EMAIL

    P_MTITLE

    P_FORMAT

    P_FILENAME

    P_ATTDESCRIPTION

    P_SENDER_ADDRESS

    P_SENDER_ADDRES_TYPE

    CHANGING P_ERROR

    P_RECIEVER.

    DATA: LD_ERROR TYPE SY-SUBRC,

    LD_RECIEVER TYPE SY-SUBRC,

    LD_MTITLE LIKE SODOCCHGI1-OBJ_DESCR,

    LD_EMAIL LIKE SOMLRECI1-RECEIVER,

    LD_FORMAT TYPE SO_OBJ_TP ,

    LD_ATTDESCRIPTION TYPE SO_OBJ_NAM ,

    LD_ATTFILENAME TYPE SO_OBJ_DES ,

    LD_SENDER_ADDRESS LIKE SOEXTRECI1-RECEIVER,

    LD_SENDER_ADDRESS_TYPE LIKE SOEXTRECI1-ADR_TYP,

    LD_RECEIVER LIKE SY-SUBRC.

    LD_EMAIL = P_EMAIL.

    LD_MTITLE = P_MTITLE.

    LD_FORMAT = P_FORMAT.

    LD_ATTDESCRIPTION = P_ATTDESCRIPTION.

    LD_ATTFILENAME = P_FILENAME.

    LD_SENDER_ADDRESS = P_SENDER_ADDRESS.

    LD_SENDER_ADDRESS_TYPE = P_SENDER_ADDRES_TYPE.

    • Fill the document data.

    W_DOC_DATA-DOC_SIZE = 1.

    • Populate the subject/generic message attributes

    W_DOC_DATA-OBJ_LANGU = SY-LANGU.

    W_DOC_DATA-OBJ_NAME = 'SAPRPT'.

    W_DOC_DATA-OBJ_DESCR = LD_MTITLE .

    W_DOC_DATA-SENSITIVTY = 'F'.

    • Fill the document data and get size of attachment

    CLEAR W_DOC_DATA.

    READ TABLE IT_ATTACH INDEX W_CNT.

    W_DOC_DATA-DOC_SIZE =

    ( W_CNT - 1 ) * 255 + STRLEN( IT_ATTACH ).

    W_DOC_DATA-OBJ_LANGU = SY-LANGU.

    W_DOC_DATA-OBJ_NAME = 'SAPRPT'.

    W_DOC_DATA-OBJ_DESCR = LD_MTITLE.

    W_DOC_DATA-SENSITIVTY = 'F'.

    CLEAR T_ATTACHMENT.

    REFRESH T_ATTACHMENT.

    T_ATTACHMENT[] = PIT_ATTACH[].

    • Describe the body of the message

    CLEAR T_PACKING_LIST.

    REFRESH T_PACKING_LIST.

    T_PACKING_LIST-TRANSF_BIN = SPACE.

    T_PACKING_LIST-HEAD_START = 1.

    T_PACKING_LIST-HEAD_NUM = 0.

    T_PACKING_LIST-BODY_START = 1.

    T_PACKING_LIST-OBJ_NAME = 'stb'.

    DESCRIBE TABLE IT_MESSAGE LINES T_PACKING_LIST-BODY_NUM.

    T_PACKING_LIST-DOC_TYPE = 'RAW'.

    APPEND T_PACKING_LIST.

    • Create attachment notification

    T_PACKING_LIST-TRANSF_BIN = 'X'.

    T_PACKING_LIST-HEAD_START = 1.

    T_PACKING_LIST-HEAD_NUM = 1.

    T_PACKING_LIST-BODY_START = 1.

    DESCRIBE TABLE T_ATTACHMENT LINES T_PACKING_LIST-BODY_NUM.

    • T_PACKING_LIST-DOC_TYPE = LD_FORMAT.

    T_PACKING_LIST-DOC_TYPE = 'XLS'.

    • T_PACKING_LIST-OBJ_DESCR = LD_ATTDESCRIPTION.

    T_PACKING_LIST-OBJ_DESCR = 'Sales_STB'.

    • T_PACKING_LIST-OBJ_NAME = LD_ATTFILENAME.

    T_PACKING_LIST-OBJ_NAME = 'stb'.

    T_PACKING_LIST-DOC_SIZE = T_PACKING_LIST-BODY_NUM * 255.

    APPEND T_PACKING_LIST.

    • Add the recipients email address

    CLEAR T_RECEIVERS.

    REFRESH T_RECEIVERS.

    LOOP AT IT_RECV.

    T_RECEIVERS-RECEIVER = IT_RECV-EMAIL.

    T_RECEIVERS-REC_TYPE = 'U'.

    • T_RECEIVERS-COM_TYPE = 'INT'.

    • T_RECEIVERS-COPY = 'X'.

    • T_RECEIVERS-NOTIF_DEL = 'X'.

    • T_RECEIVERS-NOTIF_NDEL = 'X'.

    APPEND T_RECEIVERS.

    ENDLOOP.

    CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

    EXPORTING

    DOCUMENT_DATA = W_DOC_DATA

    PUT_IN_OUTBOX = 'X'

    SENDER_ADDRESS = LD_SENDER_ADDRESS

    SENDER_ADDRESS_TYPE = LD_SENDER_ADDRESS_TYPE

    COMMIT_WORK = 'X'

    IMPORTING

    SENT_TO_ALL = W_SENT_ALL

    TABLES

    PACKING_LIST = T_PACKING_LIST

    CONTENTS_BIN = T_ATTACHMENT

    CONTENTS_TXT = IT_MESSAGE

    RECEIVERS = T_RECEIVERS

    EXCEPTIONS

    TOO_MANY_RECEIVERS = 1

    DOCUMENT_NOT_SENT = 2

    DOCUMENT_TYPE_NOT_EXIST = 3

    OPERATION_NO_AUTHORIZATION = 4

    PARAMETER_ERROR = 5

    X_ERROR = 6

    ENQUEUE_ERROR = 7

    OTHERS = 8.

    • Populate zerror return code

    LD_ERROR = SY-SUBRC.

    • Populate zreceiver return code

    LOOP AT T_RECEIVERS.

    LD_RECEIVER = T_RECEIVERS-RETRN_CODE.

    ENDLOOP.

    ENDFORM. "SEND_FILE_AS_EMAIL_ATTACHMENT

    &----


    *& Form INITIATE_MAIL_EXECUTE_PROGRAM

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM INITIATE_MAIL_EXECUTE_PROGRAM .

    WAIT UP TO 2 SECONDS.

    SUBMIT RSCONN01 WITH MODE = 'INT'

    WITH OUTPUT = ''

    AND RETURN.

    ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM

    Regards

    Subramanian

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 31, 2007 at 04:42 PM

    Hi,

    Check SO_NEW_DOCUMENT_ATT_SEND_API1.

    Ashvender

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 31, 2007 at 05:13 PM

    try these examples

    bcs_example_1

    bcs_example_2

    bcs_example_3

    bcs_example_4

    bcs_example_5

    bcs_example_6

    regards

    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.