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: 

mailing issue

Former Member
0 Kudos
211

Hye techies..

I am sending a mail using methods, while i am sending the mails using FM 'SO DOCUMENT SEND AP11' the mail is sent correctly. Please help, code for your refernce



DATA: l_send_request  TYPE REF TO cl_bcs,
         l_document      TYPE REF TO cl_document_bcs,
         l_sender        TYPE REF TO cl_sapuser_bcs,
         l_sub           TYPE char50,
         l_recipient     TYPE REF TO if_recipient_bcs,
         tl_contents     TYPE STANDARD TABLE OF soli,
         l_doc_len       TYPE so_obj_len,
         l_cnt           TYPE sy-tabix,
         l_rcv_email     TYPE adr6-smtp_addr,
         l_result        TYPE sy-binpt,
         l_bcs_exception TYPE REF TO cx_bcs,
         l_subj          TYPE string,
         wl_mailid       TYPE somlreci1-receiver .
  TRY.

*-- Create persistent send request
      l_send_request = cl_bcs=>create_persistent( ).
      tl_contents[] = bodytable[].

* subject of the mail
      l_sub = 'HTML format'.

*Get the length of the Document
      DESCRIBE TABLE tl_contents LINES l_cnt.
      READ TABLE tl_contents INTO body INDEX l_cnt.
      l_doc_len = ( l_cnt - 1 ) * 255 + STRLEN( body ).

---


*-- Create Document
      l_document = cl_document_bcs=>create_document(
                   i_type       = 'HTM'
                   i_text       = tl_contents
                   i_length     = l_doc_len
                   i_subject    = l_sub
                   i_language   = sy-langu
                   i_importance = '1' ).
      TRY.
*-- Set the Message Subject
          CALL METHOD l_send_request->set_message_subject
            EXPORTING
              ip_subject = l_subj.
        CATCH cx_sy_dyn_call_illegal_method.
      ENDTRY.
*-- Add document to send request
      CALL METHOD l_send_request->set_document( l_document ).

*-- Do send delivery info for successful mails
      CALL METHOD l_send_request->set_status_attributes
        EXPORTING
          i_requested_status = 'E'
          i_status_mail      = 'A'.

DATA: user type uname.
      user = 'OPTIMA-ADMN'.

*-- Set sender
      l_sender = cl_sapuser_bcs=>create( user ).
      CALL METHOD l_send_request->set_sender
        EXPORTING
          i_sender = l_sender.

      LOOP AT s_mail.
        l_rcv_email = s_mail-low.
      ENDLOOP.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
146

Hi,

Is it returning any exception.If yes what is it. Also check in SU01D transaction if there is an user called ''OPTIMA-ADMN'. The sender you marked is this. If there is no account created for this user it will throw exception.

Thanks

Papiya

Edited by: Papiya chatterjee on Aug 31, 2009 1:11 PM

9 REPLIES 9

Former Member
0 Kudos
146

Continuation for the program


DATA: user type uname.
      user = 'OPTIMA-ADMN'.

*-- Set sender
      l_sender = cl_sapuser_bcs=>create( user ).
      CALL METHOD l_send_request->set_sender
        EXPORTING
          i_sender = l_sender.

      LOOP AT s_mail.
        l_rcv_email = s_mail-low.
      ENDLOOP.

      l_recipient = cl_cam_address_bcs=>create_internet_address(
                                                            l_rcv_email ).
      CALL METHOD l_send_request->add_recipient
        EXPORTING
          i_recipient = l_recipient.
          "i_express   = 'X'.
*-- Send Email
      CALL METHOD l_send_request->send(
          EXPORTING
            i_with_error_screen = 'X'
          RECEIVING
            result              = l_result ).

      IF l_result = 'X'.
        MESSAGE s999(zz) WITH
        'Approval Mail Sent Successfully'(003).
      ENDIF.



    CATCH cx_bcs INTO l_bcs_exception.
      IF l_result NE 'X'.
        MESSAGE s999(zz) WITH
        'Approval Mail Not Successful'(004).
      ENDIF.


  ENDTRY.

the l_result is also returning X.

Please check .

Regards,

Imran.

0 Kudos
146

Hi,

Check the links

https://wiki.sdn.sap.com/wiki/display/Snippets/SendMailhavingMultipleFilesasAttachmentusingobjectorientedtechnique

Today's [Blog|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/15570] [original link is broken] [original link is broken] [original link is broken];

Regards,

Amit

Edited by: Amit Iyer on Aug 31, 2009 4:03 PM

RahulKeshav
Active Contributor
0 Kudos
146

so whats the issue....

0 Kudos
146

hye keshav,

the mail is not triggered by using the above code.

Regards,

Imran.

0 Kudos
146

Check Txn SCOTT..

and execute...

0 Kudos
146

Hi,

do you see the email in tcode SOST?

Regards, Dieter

Former Member
0 Kudos
147

Hi,

Is it returning any exception.If yes what is it. Also check in SU01D transaction if there is an user called ''OPTIMA-ADMN'. The sender you marked is this. If there is no account created for this user it will throw exception.

Thanks

Papiya

Edited by: Papiya chatterjee on Aug 31, 2009 1:11 PM

0 Kudos
146

hye papiya,

The user is existent, also no entry in SOST. the mail is not at all triggered, i guess any suggestion.

No exceptions too.

Regards,

imran

0 Kudos
146

try txn SCOT .....

and execute....