Skip to Content
author's profile photo Former Member
Former Member

Sending email from webdynpro

Dear all,

I have developed a webdynpro application.

Now my requirement is that i would like to send the URL of this application through an email to the user and then the user can run the application from there when he clicks on the URL/Link...

have the URL with me.

What i want to do is , I have a submit button but when ever requester submits the webdynpro form, I need to send one mail to approver.

so that he can run the application from the mail using the URL.

I tried with following fm's but there is no mail in sost.

SO_NEW_DOCUMENT_ATT_SEND_API1

SO_DOCUMENT_SEND_API1

Has anyone an example how to send an email with Webdynpro for Abap.

Thanks,

Ravi.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Feb 07, 2012 at 07:50 PM

    Hi Ravi,

    As Thomas said, first check that SAP is configured for sending external mails. You can use below code for sending mails:

    
      CLASS cl_bcs DEFINITION LOAD.
    
      DATA:
        lo_send_request TYPE REF TO cl_bcs VALUE IS INITIAL.
    
      lo_send_request = cl_bcs=>create_persistent( ).
    
    * Message body and subject
      DATA:
      lt_message_body TYPE bcsy_text VALUE IS INITIAL,
      lo_document TYPE REF TO cl_document_bcs VALUE IS INITIAL.
      APPEND 'Dear,' TO lt_message_body.
      APPEND ' ' TO lt_message_body.
      APPEND 'Please fill the attached form and send it back to us.'
      TO lt_message_body.
      APPEND "URL" TO lt_message_body.
      APPEND 'Thank You,' TO lt_message_body.
    
      lo_document = cl_document_bcs=>create_document(
      i_type = 'RAW'
      i_text = lt_message_body
      i_subject = 'Personnel Information Form' ).
    
      DATA: lx_document_bcs TYPE REF TO cx_document_bcs VALUE IS INITIAL.
    
    * Pass the document to send request
      lo_send_request->set_document( lo_document ).
    
    * Create sender
      DATA:
      lo_sender TYPE REF TO if_sender_bcs VALUE IS INITIAL,
      l_send TYPE adr6-smtp_addr VALUE 'SENDER_ID',
      l_reci TYPE adr6-smtp_addr.
    
      l_reci = 'user_name_at_company_dot_com'. "Approver's email address
    
    
    *  lo_sender = cl_cam_address_bcs=>create_internet_address( l_send ).
      lo_sender = cl_sapuser_bcs=>create( sy-uname ).
    * Set sender
      lo_send_request->set_sender(
      EXPORTING
      i_sender = lo_sender ).
    
    * create recipient
      DATA:
      lo_recipient TYPE REF TO if_recipient_bcs VALUE IS INITIAL.
      lo_recipient = cl_cam_address_bcs=>create_internet_address( l_reci ).
    ** Set recipient
      lo_send_request->add_recipient(
      EXPORTING
      i_recipient = lo_recipient
      i_express = 'X' ).
    *  lo_send_request->add_recipient(
    *  EXPORTING
    *  i_recipient = lo_recipient
    *  i_express = 'X' ).* Send email
      DATA: lv_sent_to_all(1) TYPE c VALUE IS INITIAL.
      lo_send_request->send(
      EXPORTING
      i_with_error_screen = 'X'
      RECEIVING
      result = lv_sent_to_all ).
      COMMIT WORK.
    
    
    

    Hope this will help,

    Amit

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 07, 2012 at 04:19 PM

    There is nothing web dynpro specific about sending emails. These function modules should work find - although in general you should use the CL_BCS classes for sending emails in all cases. Are you sure Email is configured correctly on your system? Can you send a test email from a standard application or by copying this functionality into a dynpro application?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 14, 2014 at 05:56 AM

    This message was moderated.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.