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: 

Sending mail through FM : SO_NEW_DOCUMENT_SEND_API1

Former Member
0 Kudos

Dear Friends,

I am using the Function Module : SO_NEW_DOCUMENT_SEND_API1 to send mails to MS Outlook. My program is working perfectly fine, when I execute in the foreground. However, when I schedule a job for the same program, it is throwing up an exception. Not sure if it something to do with the user authorization? In fact, user has full authorization. Could someone help on this?

Regards,

Chandru

2 REPLIES 2

Former Member
0 Kudos

Hi Chandru,

Please specify the exception. and if possible paste your function call(code) here

0 Kudos

Here we go...

  • get the 'To' email address. " Receiver mail id.

clear buyer_receivers.

buyer_receivers-receiver = wa_zmala-smtp_addr.

buyer_receivers-rec_type = 'U'.

buyer_receivers-copy = ' '.

append buyer_receivers.

  • get the 'CC' email address. " Reply back mail id.

clear buyer_receivers.

buyer_receivers-receiver = wa_zmala-rbmail.

buyer_receivers-rec_type = 'U'.

buyer_receivers-copy = 'X'. " Indicates a carbon copy

append buyer_receivers.

  • get the subject of the mail.

concatenate sy-sysid wa_zmala-bukrs 'SINA' 'DocID'

wa_zmala-documentid wa_zmala-vname into subject_data-obj_descr

separated by '-'.

subject_data-obj_langu = sy-langu.

subject_data-sensitivty = 'F'. " indicates functional

call function 'SO_NEW_DOCUMENT_SEND_API1'

exporting

document_type = 'RAW'

document_data = subject_data

put_in_outbox = 'X'

tables

object_content = object_content

receivers = buyer_receivers

exceptions

too_many_receivers = 2

document_not_sent = 3

document_type_not_exist

operation_no_authorization

parameter_error

x_error

enqueue_error

document_not_sent = 2

others = 99.

case sy-subrc.

when 0.

update zmalainbox set

mail_date = sy-datum

mail_time = sy-uzeit

where documentid = wa_zmala-documentid.

condense temp_mailid1. condense temp_mailid2.

write: / temp_docid, text-002, temp_mailid1, ',', temp_mailid2.

uline.

when others.

write: / temp_docid, text-003.

uline.

endcase.

endform

form initiate_mail_send_program.

submit rsconn01 with mode = 'INT'

with output = 'X'

and return.

endform.