Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Reading GOS-Attachment and send via Mail

Peter_Lintner
Participant
0 Kudos

Hi!

I've to read attachments of a BOR-Object and attach them to a mail. This should work in background.

Does anybody know a way to implement such a functionality?

Which methods or FMs should be used to read the attachments?

I want to use the FM SO_NEW_DOCUMENT_ATT_SEND_API1 to send the mail.

Any hints are welcome!

Thanks and regards,

Peter

1 ACCEPTED SOLUTION

Peter_Lintner
Participant
0 Kudos

Hi!

Thanks for your answers, but I think, I have not expressed my question clearly.

I know how to send mails with and without attachments.

I don't know any way how to read attachments of BOR-Objects to attach them to this mail. This should work in background.

Thanks for any hints!

Peter

7 REPLIES 7

suresh_datti
Active Contributor
0 Kudos

Hi Peter,

PL check this function module SGOS_SEND_OBJECT_WITH_NOTE.

Regards,

Suresh Datti

vinod_gunaware2
Active Contributor
0 Kudos

These are the FM for sending external email :-

SO_DOCUMENT_SEND_API1

SAPoffice: Send new document with attachments via RFC

SO_NEW_DOCUMENT_ATT_SEND_API1

(In 4.6C only, You can go to SE37 and click the documentation on how to use it. A sample program is provided there.)

SAPoffice: Send new document with attachments via RFC

Note : If you are using FM SO_NEW_DOCUMENT_ATT_SEND_API1 then Export Parameter DOCUMENT_DATA-OBJ_DESCR contains the Subject.

SO_NEW_DOCUMENT_SEND_API1

SAPoffice: Send new document

FORM SEND_MAIL.

DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.

DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.

DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.

DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.

DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.

DATA: DOC_CHNG LIKE SODOCCHGI1.

DATA: TAB_LINES LIKE SY-TABIX.

DATA L_NUM(3).

  • Creation of the document to be sent

  • File Name

DOC_CHNG-OBJ_NAME = 'SENDFILE'.

  • Mail Subject

DOC_CHNG-OBJ_DESCR = 'Delivered Mail'.

  • Mail Contents

OBJTXT = 'Object text'.

APPEND OBJTXT.

DESCRIBE TABLE OBJTXT LINES TAB_LINES.

READ TABLE OBJTXT INDEX TAB_LINES.

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

  • Creation of the entry for the compressed document

CLEAR OBJPACK-TRANSF_BIN.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 0.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = TAB_LINES.

OBJPACK-DOC_TYPE = 'RAW'.

APPEND OBJPACK.

  • Creation of the document attachment

LOOP AT ITAB_DATA.

CONCATENATE ITAB_DATA-PRODUCTOR

ITAB_DATA-VBELN

ITAB_DATA-POSNR

ITAB_DATA-MATNR INTO OBJBIN.

APPEND OBJBIN.

ENDLOOP.

DESCRIBE TABLE OBJBIN LINES TAB_LINES.

OBJHEAD = 'ORDERS'.

APPEND OBJHEAD.

    • Creation of the entry for the compressed attachment

OBJPACK-TRANSF_BIN = 'X'.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 1.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = TAB_LINES.

OBJPACK-DOC_TYPE = 'TXT'.

OBJPACK-OBJ_NAME = 'WEBSITE'.

OBJPACK-OBJ_DESCR = 'ORDERS.TXT'.

OBJPACK-DOC_SIZE = TAB_LINES * 255.

APPEND OBJPACK.

  • Completing the recipient list

  • target recipent

clear RECLIST.

RECLIST-RECEIVER = 'test@here.com'.

RECLIST-EXPRESS = 'X'.

RECLIST-REC_TYPE = 'U'.

APPEND RECLIST.

  • copy recipents

clear RECLIST.

RECLIST-RECEIVER = 'secondtest@here.com'.

RECLIST-EXPRESS = 'X'.

RECLIST-REC_TYPE = 'U'.

RECLIST-COPY = 'X'.

APPEND RECLIST.

  • Sending the document

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = DOC_CHNG

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.

ENDFORM. " SEND_MAIL

0 Kudos

Hi,

Check this thread,...

Regards

vijay

Peter_Lintner
Participant
0 Kudos

Hi!

Thanks for your answers, but I think, I have not expressed my question clearly.

I know how to send mails with and without attachments.

I don't know any way how to read attachments of BOR-Objects to attach them to this mail. This should work in background.

Thanks for any hints!

Peter

0 Kudos

Hello,

I have the same problem. Do you find a solution ?

Thank you

Marielle

0 Kudos

Hi,

I also have the similar problem. Need to retrive all the attachements for a document and provide option to select some of attchments and mail the selected attachments.

Please let me know if anyone have solution.

Thanks in advance.

0 Kudos

Check out this thread...

Thanks,

Ram