mail to sap inbox

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

Post Reply
suresh

mail to sap inbox

Post by suresh » Mon Oct 21, 2002 12:09 am

hi all,

it nice to see sapfans back.

i need a function module where i can send a mail to sap inbox.
i should be able to send text and also attachements to it.

tqs

TwoABAPers
Posts: 990
Joined: Sun Oct 20, 2002 9:16 pm
Location: web
Contact:

Post by TwoABAPers » Mon Oct 21, 2002 12:16 am

SO_NEW_DOCUMENT_ATT_SEND_API1

Regards
Sudhir/Mohit

guest_SAP

Can anyone give me a sample code for this FM

Post by guest_SAP » Tue Dec 03, 2002 11:29 am

I am trying to use the FM SO_NEW_DOCUMENT_ATT_SEND_API1, But it will be nice to have some sample code for it.

Can anyone put it here.

Thanks.

kumar
Posts: 2012
Joined: Tue Oct 22, 2002 12:51 pm
Location: Basel, Switzerland
Contact:

Post by kumar » Tue Dec 03, 2002 12:06 pm

A sample is as follows

Code: Select all


REPORT ZMAIL.

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.

* Creation of the document to be sent
* File Name
DOC_CHNG-OBJ_NAME = 'SENDFILE'.
* Mail Subject
CONCATENATE SY-DATUM 'Send External Mail' SY-UZEIT INTO
DOC_CHNG-OBJ_DESCR SEPARATED BY SPACE.
*OC_CHNG-OBJ_DESCR = 'Send External Mail'.
* Mail Contents
OBJTXT = 'Testing sending Mails'.
APPEND OBJTXT.
OBJTXT = 'First sentence by Kumar K Rangaraj ABAP Programmer'.
APPEND OBJTXT.
OBJTXT = 'Second line for Kumar KR, Britain'.
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.


* Completing the recipient list
RECLIST-RECEIVER = 'kumaraparna@rediffmail.com'.
RECLIST-REC_TYPE = 'U'.
RECLIST-EXPRESS = 'X'.
APPEND RECLIST.
RECLIST-RECEIVER = 'KRANGARAJ'. "User your SAP User Name
RECLIST-REC_TYPE = 'B'.
RECLIST-EXPRESS = 'X'.
APPEND RECLIST.

*RECLIST-RECEIVER = 'SAPUSERNAME'.
*RECLIST-REC_TYPE = 'P'.
*APPEND RECLIST.

* Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
   DOCUMENT_DATA = DOC_CHNG
   PUT_IN_OUTBOX = SPACE
*   PUT_IN_OUTBOX = 'X'
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.
   WRITE: / 'Result of the send process:'.

LOOP AT RECLIST.
   WRITE: / RECLIST-RECEIVER(48), ':'.

   IF RECLIST-RETRN_CODE = 0.
      WRITE 'The document was sent'.
   ELSE.
      WRITE 'The document could not be sent'.
ENDIF.

ENDLOOP.

WHEN 1.
   WRITE: / 'No authorization for sending to the specified number',
            'of recipients'.

WHEN 2.
   WRITE: / 'Document could not be sent to any recipient'.

WHEN 4.
   WRITE: / 'No send authorization'.

WHEN OTHERS.
   WRITE: / 'Error occurred while sending'.

ENDCASE.

Ensure that you fill YOUR eMAIL ID as I receive a lot of test copies in my email.

KRK

guest_SAP

Thanks...

Post by guest_SAP » Wed Dec 04, 2002 9:43 am

Thanks for the help... I will make sure I remove your email.

Thanks

Guest

Post by Guest » Tue Dec 17, 2002 3:39 pm

Hi all.

I´m tryng to use this function but I need to send an attachement type PDF.
Is this possible?

Thanks in advance

Guest

Post by Guest » Tue Apr 01, 2003 4:41 pm

How to use this FM for PDF? Please let me know..

Jennie

manohar
Posts: 168
Joined: Sun Oct 20, 2002 10:50 pm
Location: Bangalore, India.

Post by manohar » Wed Apr 02, 2003 3:41 am

Anonymous wrote:How to use this FM for PDF? Please let me know..

I have tried with this FM but not able to upload the files, there is the other way which i have approached...but this will not work in background, as it picks file from presentation server.
Refer to viewtopic.php?t=22468&highlight=
or we have to use the sequence of FM to send an attachment, like SO_ATTACHMENT_INSERT :roll:
Best Regards
Manohar

New

Post by New » Wed Apr 02, 2003 3:28 pm

does this works from SAP to my personal mail id?

i am getting error...
can anyone clarify?

thanks
mlnaras

Post Reply