10-07-2008 12:37 PM
Hi experts
I need a FM to send a external email on some particular date.
Thanks
Bijal
10-07-2008 12:40 PM
Hello,
See these:
[SAP Network Blog: Sending E-Mail from ABAP - Version 610 and Higher - BCS Interface|https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/789] [original link is broken] [original link is broken] [original link is broken];
[Sending E-Mail from ABAP - Version 46D and Lower - API Interface|https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/781] [original link is broken] [original link is broken] [original link is broken];
Regards.
10-07-2008 12:43 PM
>
> Hi experts
>
> I need a FM to send a external email on some particular date.
>
> Thanks
> Bijal
You can send mails with attachements using SO_DOCUMENT_SEND_API1. Use this FM in a Z program and schedule it in to execute on that perticular date.
10-07-2008 12:49 PM
Sample code
DATA : l_atch_name(50) TYPE c.
CONCATENATE text-022 sy-datum '.xls' INTO l_atch_name.
Fill the document data.
DESCRIBE TABLE t_message LINES g_w_cnt.
gd_doc_data-doc_size = ( g_w_cnt - 1 ) * 255 + STRLEN( t_message ).
Populate the subject/generic message attributes
gd_doc_data-obj_langu = sy-langu.
gd_doc_data-obj_name = 'CHANGEPOINTERS'.
gd_doc_data-obj_descr = text-016.
gd_doc_data-sensitivty = 'F'.
Populate the attachment table
CLEAR t_attachment.
REFRESH t_attachment.
APPEND LINES OF t_attach TO t_attachment.
Attachment
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = 'XLS'.
t_packing_list-obj_descr = l_atch_name.
t_packing_list-obj_name = 'TEST'.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
LOOP AT s_email.
t_receivers-receiver = s_email-low.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
ENDLOOP.
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'
TABLES
packing_list = t_packing_list
contents_txt = t_message
contents_bin = t_attachment
receivers = t_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.
Store function module return code
gd_error = sy-subrc.