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: 

External Emails

Former Member
0 Kudos
264

Hi ,

Am trying to send individual emails to sap users with thier details.Am using the FM

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE' from reading emials address of users into an internal table. To send individual email am looping around the internal table and passing it the details FM call function 'SO_NEW_DOCUMENT_ATT_SEND_API1' . The problem is, instead of sending individual details its sending all information in a mail. The code is as below. Could you please let me know if there is any issue which am missing.

LOOP AT gt_userdata INTO gs_userdata.

  • * Fill the document data.

gd_doc_data-doc_size = 1.

  • Populate the subject/generic message attributes

gd_doc_data-obj_langu = sy-langu.

gd_doc_data-obj_name = 'SAPRPT'.

gd_doc_data-obj_descr = psubject.

gd_doc_data-sensitivty = 'F'.

  • 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.

DATA P_EMAIL TYPE SO_RECNAME.

CLEAR p_email.

P_EMAIL = gs_userdata-user_email.

  • Add the recipients email address

clear it_receivers.

refresh it_receivers.

it_receivers-receiver = p_email.

it_receivers-rec_type = 'U'.

it_receivers-com_type = 'INT'.

it_receivers-notif_del = 'X'.

it_receivers-notif_ndel = 'X'.

append it_receivers.

  • Call the FM to post the message to SAPMAIL

call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = gd_doc_data

put_in_outbox = 'X'

commit_work = 'X'

  • 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.

ENDLOOP.

Thanks,

Kumar

11 REPLIES 11

Former Member
0 Kudos
211
The problem is, instead of sending individual details its sending all information in a mail. 
The code is as below. 

Could be please explain a bit more.

0 Kudos
211

Hi,

The Emails sent contains user detials which should be sent to particular user email id only , but while sending emails using the above code its sending all other user details information to one person though the correct records (Email ids ) are been passed through the loop from internal table .

Thanks,

Vind

Former Member
0 Kudos
211

Hi,

After calling the FM, try putting code like below.

IF sy-subrc = 0.
          SUBMIT rsconn01  WITH mode = 'INT'
                           WITH output = space
                           AND RETURN.
ENDIF.

0 Kudos
211

Hi,

I have put the following code after the FM module, but when i check the TC SOST there are no emails that's been sent to the users.

Can you please let me know wht is the issue.

Thanks,

Kumar.

0 Kudos
211

check the TC SCOT settings for that, If its not configured properly, email will not go.

0 Kudos
211

Hi,

Connection are fine but have the same issue of not sending individual emails users.

Thanks,

Kumar.

0 Kudos
211

Hi,

Can you please check in the t-code SBWP outbox. There you can see the send mails and their status.

0 Kudos
211

Hi Raaj,

I can see all the emails but with same problem. Have to send p/w details to users so the mail should inculde only those persons details but not others along with this user. This is mass process program of sending p/w details to individuls from excel sheet.

Thanks,

Kumar.

0 Kudos
211

you mean to say in the internet node in SCOT the reciepents mail id or the domain is maintained.. even then its not reflecting in SOST or is it in waiting status in SOST and not going to the user. If its not reflecting in SOST, since you have put the put in outbox option also , check there in the outbox.. if its there then its the configuration issue.. if its in the waitng status u can manually trigger sending it..

Former Member
0 Kudos
211

In your code, the it_message is not updated inside the loop so its sending the same details to all the user's mail id.

Former Member
0 Kudos
211

solved