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: 

SO_DOCUMENT_SEND_API1 - Sending external mail with changed sender

Former Member
0 Kudos
455

Hi.

I'm trying to send an external e-mail and when the recipient replies it must go back to a different sender. Sending the e-mail is no problem, but I can't seem to change the sender e-mail. I've tried different sender address types: 'U' - return error 6 (X_ERROR) and 'SMTP' & 'INT' sends the mail but the reply does not work. I've the code at the bottom.

I've read a lot of similar posts on SCN but none have been able to help me.

Any suggestions would be appreciated.

concatenate 'TEST 1' 'TEST 2.'

       into ws_text separated by space.

     append ws_text to it_message.

     gd_doc_data-obj_name = 'SAP Inbox Message'.

     gd_doc_data-obj_langu = sy-langu.

     gd_doc_data-obj_descr = 'Accept or Reject'.

*Describe the body of the message

     clear it_packing_list.

     refresh it_packing_list.

     it_packing_list-transf_bin = space.

     it_packing_list-head_start = 1.

     it_packing_list-head_num = 0.

     it_packing_list-body_start = 1.

     describe table it_message lines it_packing_list-body_num.

     it_packing_list-doc_type = 'RAW'.

     append it_packing_list.

* Add the recipients email address

     SELECT SINGLE * FROM ZMAIL_floor_pers    "get first person on e-mail table

*      INTO P_MAIL

       WHERE MAIL_NR = '01'.

     clear it_receivers.

     refresh it_receivers.

     it_receivers-receiver = ZMAIL_floor_pers-EMAIL.  

     it_receivers-rec_type = 'U'.

     it_receivers-com_type = 'INT'.

     it_receivers-notif_del = 'X'.

     it_receivers-notif_ndel = 'X'.

     append it_receivers.

     SELECT SINGLE * FROM USR21 WHERE BNAME = SY-UNAME.

     SELECT SINGLE SMTP_ADDR FROM ADR6 INTO V_ADDR

                                       WHERE ADDRNUMBER = USR21-ADDRNUMBER

                                         AND PERSNUMBER = USR21-PERSNUMBER

                                         AND CONSNUMBER = '002'.

     V_EMAIL = V_ADDR.

     call function 'SO_DOCUMENT_SEND_API1'

       EXPORTING

         document_data              = gd_doc_data

         put_in_outbox                = 'X'

         sender_address             = V_EMAIL

         sender_address_type     = 'SMTP'

       IMPORTING

         sent_to_all                = gd_sent_all

       TABLES

         packing_list               = it_packing_list

         contents_txt               = it_message

         receivers                  = it_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.



3 REPLIES 3

Former Member
0 Kudos
115

c'mon, Edwin....many, many posts on this subject and had you searched you would have found that these antique APIs either won't or will allow sender change, depending upon which one you are using.  If you are writing new code, junk that out-of-date API call and do as so many have suggested in this forum....use current SAP email technology, Class BCS for Business Communications Services, for which you can find many demonstration programs that will show how to do what you want, named like BCS_TEST*

0 Kudos
115

Thanks Break Point. I agree with you 100%. There is a reason why I used "old SAP technology". Please see this link: http://scn.sap.com/thread/3196141.

I could not get the methods to work in the system I need. Maybe you have an idea on this?

0 Kudos
115

The methods actually work beautifully.... You didn't try to call a screen from background processing, or something, did you?  If you're running in background, there is NO connection to a presentation server, e.g., no connection to a desktop.  When you're going to execute programs in background (or both foreground and background), it is essential to consider the content of sy-batch..."X" means we're in background, so don't make any calls or try to send anything to a screen....