Application Development and Automation 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: 
Read only

How to set Email header using SO_NEW_DOCUMENT_SEND_API1

Former Member
0 Likes
1,771

Hi experts,

I got the task to send emails with special information in the header. It's a kind of email interface to a non SAP system, and some of the control information should be stored in the email header. For example, an additional header info like the following should be added to the header of an outgoing email.

X-routingstring: useway_4

I've checked SDN so far, but didn't find anything. I've tried to use table parameter object_header of function SO_NEW_DOCUMENT_SEND_API1, but the lines I've added, did not show up in the header of the outgoing email.

Does anyone have an idea, how to add information to the header?

Thx!!

Hi experts,

I got the task to send emails with special information in the header. It's a kind of email interface to a non SAP system, and some of the control information should be stored in the email header. For example, an additional header info like the following should be added to the header of an outgoing email.

X-routingstring: useway_4

I've checked SDN so far, but didn't find anything. I've tried to use table parameter object_header of function SO_NEW_DOCUMENT_SEND_API1, but the lines I've added, did not show up in the header of the outgoing email.

Does anyone have an idea, how to add information to the header?

Thx!!

7 REPLIES 7
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,336

(FAQ) Did you use the search tool at scn ?

There are already many samples of the good old SO_NEW_DOCUMENT_SEND_API1 FM or more recent CL_BCS class.

Regards,

Raymond

Read only

0 Likes
1,336

Hi Raymond,

thanks for the answer. Yes I did, but I didn't find any example adding field to header. I need to add customer specific X-header elements to the email sent. Using the table parameter OBJECT_HEADER of function module SO_NEW_DOCUMENT_SEND API1 did not work like this:

  ls_obj_header = 'X-CheckID: MSCE'.
APPEND ls_obj_header TO lt_obj_header.

ls_obj_header = 'X-test: Global Message Exchange <[email protected]>'.
APPEND ls_obj_header TO lt_obj_header.


CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
  EXPORTING
    document_data              = ls_document_data
    sender_address             = lv_mailsender
    sender_address_type        = 'B'
  TABLES
    object_header              = lt_obj_header
    packing_list               = lt_packing_list
    contents_txt               = lt_emailtext
    receivers                  = lt_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.

I will try adding X-Elements to the header using CL_BCS class now...

Regards,

Thilo

Read only

0 Likes
1,336

Hi Raymond,

thanks for the answer. Yes I did, but I didn't find any example adding field to header. I need to add customer specific X-header elements to the email sent. Using the table parameter OBJECT_HEADER of function module SO_NEW_DOCUMENT_SEND API1 did not work like this:

  ls_obj_header = 'X-CheckID: MSCE'.
APPEND ls_obj_header TO lt_obj_header.

ls_obj_header = 'X-test: Global Message Exchange <[email protected]>'.
APPEND ls_obj_header TO lt_obj_header.


CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
  EXPORTING
    document_data              = ls_document_data
    sender_address             = lv_mailsender
    sender_address_type        = 'B'
  TABLES
    object_header              = lt_obj_header
    packing_list               = lt_packing_list
    contents_txt               = lt_emailtext
    receivers                  = lt_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.

I will try adding X-Elements to the header using CL_BCS class now...

Regards,

Thilo

Read only

Former Member
0 Likes
1,336

I've tried it using cl_bcs, but it's the same problem: the message is sent correctly, but the header I passed to the create method does not show up in the email sent. Does anyone have an idea?

my coding:

  soli = 'X-testheader: test'.
APPEND soli TO header .

lo_document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text message_body
i_header = header
i_subject = 'testbetreff' ).

Read only

0 Likes
1,336

Hi Thilo,

did you solve it?

I have a similar requirement...

Read only

0 Likes
1,336

Hi Alessandro,

no, i didn't solve it. We found out, that it didn't work because the version of the email server connected was too old. Otherwise it should have worked .

Good luck!

Read only

0 Likes
1,336

Ok.I'll try it..thank you!