09-26-2008 8:25 PM
Hi Experts,
In my Z prog. I need to send some message to internet eloctronic mail company outlook addressess........so, am using MC_SEND_MAIL function module..........but, not working!!!!!!!!!!!!
in my testing in SE37, i tried different ways, like, i hv given my company outlook address, yahoo address, existing distribution list(so23) name..........but in any case its working!!!!!!!!!
i am passing like below,
{
CALL FUNCTION 'MC_SEND_MAIL'
EXPORTING
MS_MAIL_SENDMODE = 'B'
MS_MAIL_TITLE = ERR_TITLE
MS_MAIL_DESCRIPTION = ERR_DESC
ms_mail_receiver = I_USERS-BNAME (in 2nd trails, i passed list as z_my_list)
MS_MAIL_EXPRESS = 'X' ---> also tried with out X
MS_MAIL_LANGU = SY-LANGU
IMPORTING
MS_OK_CODE = OKCD
TABLES
MS_MAIL_CONT = T_MCMAILOBJ }
but, AM GETTING WORK FLOW EXPRESS MESSAGES CORRECTLY!!!!!
So, let me know that,
1 - Whts is the mistake? am i passing incorrectly?
2 - Can I suspect that, there is some thing mistake in SETUP of distribution list by BASIS?
then, why my outlook and yahoo r not working?
3 - i dont care, which is the FM, just I wanna to send message to my comapny outlook adressess, either as a distribution list or single id.
replies appreciated
thanq
Edited by: SAP ABAPer on Sep 26, 2008 9:25 PM
Edited by: SAP ABAPer on Sep 26, 2008 9:26 PM
09-26-2008 8:29 PM
Hello,
Go to these links: [SAP Network Blog: Sending E-Mail from ABAP - Version 610 and Higher - BCS Interface|] and [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.
09-26-2008 8:29 PM
Hello,
Go to these links: [SAP Network Blog: Sending E-Mail from ABAP - Version 610 and Higher - BCS Interface|] and [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.
09-26-2008 9:04 PM
Hi,
I reccomend using the cl_bcs class. Please have a look at the code below and see if you can use it.
REPORT ZAP_EMAIL.
PARAMETERS: a_to TYPE char30,
a_subj TYPE char50,
a_body TYPE char70.
DATA: lr_email TYPE REF TO cl_bcs,
lr_doc TYPE REF TO cl_document_bcs,
lr_sender TYPE REF TO cl_sapuser_bcs,
lr_recip TYPE REF TO if_recipient_bcs.
DATA: l_body TYPE string,
l_to TYPE AD_SMTPADR,
lt_mailtext TYPE soli_tab,
l_subj TYPE so_obj_des.
l_subj = a_subj.
l_body = a_body.
l_to = a_to.
lr_email = cl_bcs=>create_persistent( ).
CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
EXPORTING
text = l_body
tables
ftext_tab = lt_mailtext.
lr_doc = cl_document_bcs=>create_document( i_type = 'HTM'
i_text = lt_mailtext
i_subject = l_subj ).
lr_sender = cl_sapuser_bcs=>create( sy-uname ).
lr_recip = cl_cam_address_bcs=>create_internet_address( l_to ).
lr_email->set_document( lr_doc ).
lr_email->set_sender( lr_sender ).
lr_email->add_recipient( lr_recip ).
lr_email->set_status_attributes( i_requested_status = 'N'
i_status_mail = 'E' ).
lr_email->set_send_immediately( abap_true ).
lr_email->send( ).
COMMIT WORK.
WRITE: 'Email Sent to', a_to.
---
Best regards,
Andri
09-26-2008 11:45 PM
Try this FM SO_NEW_DOCUMENT_SEND_API1. It does work for sure, you can find a lot of sample programs using this FM on SDN/google.
The FM that you are using might also work.
Yes, you will need to check with BASIS if theu have configured SCOT or not. SCOT is the transaction that send your messages out of SAP though SMTP or other protocols. After you run your program for sending out email, (and BASIS configues SCOT) you will need to go SCOT and manually push your messages out of SAP.
sometime SCOT is configured to send out all messages after a few minutes interval too, but you definitily check with BASIS.
Hope it helps.
09-27-2008 4:16 AM
Give you a sample, hope it can help you.
DATA: lt_docdata LIKE sodocchgi1,
lt_objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
lt_objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
lt_objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
lt_reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE,
l_tab_lines TYPE i.
lt_docdata-obj_name = 'Send mail for testing'.
lt_docdata-obj_descr = 'For Testing'.
lt_objtxt = 'Error List:'. APPEND lt_objtxt.
lt_objtxt = 'Error One:'. APPEND lt_objtxt.
lt_objtxt = 'Error Two:'. APPEND lt_objtxt.
lt_objtxt = 'Error Three:'. APPEND lt_objtxt.
DESCRIBE TABLE lt_objtxt LINES l_tab_lines.
READ TABLE lt_objtxt INDEX l_tab_lines.
lt_docdata-doc_size = ( l_tab_lines - 1 ) * 255
+ STRLEN( lt_objtxt ).
CLEAR lt_objpack-transf_bin.
lt_objpack-head_start = 1. lt_objpack-head_num = 0.
lt_objpack-body_start = 1. lt_objpack-body_num = l_tab_lines.
lt_objpack-doc_type = 'RAW'. " RAW ->SAP
APPEND lt_objpack.
lt_reclist-rec_type = 'U'.
lt_reclist-receiver = 'email address here'.
APPEND lt_reclist.
lt_reclist-rec_type = 'U'.
lt_reclist-receiver = 'email address here'.
APPEND lt_reclist.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = lt_docdata
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = lt_objpack
object_header = lt_objhead
contents_txt = lt_objtxt
receivers = lt_reclist
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.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.