Skip to Content
0
Former Member
Jun 21, 2012 at 03:25 PM

SO_DOCUMENT_SEND_API1 - Sending external mail with changed sender

326 Views

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.