Skip to Content

sending mail to gmail address

Hi experts,

In my requirement i want to send the output of the report to my personal gmail address. I am very new to this concept please provide detail information .

Any documents is available it is better for me.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2014 at 10:20 AM

    Hi Krishna,

    If your question is confined to sending email to "gmail.com" or any similar domains.The you need to check with Basis guys.

    Usually they will configure the system so that no mails can be sent to external domains.

    Mails from SAP are allowed to the own company domain only.

    --Lakshmi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2014 at 10:54 AM

    Hi Krishna

    Please check in Transaction SCOT - if the configurations are maintained. We can restrict email ID's for which mails are allowed to be sent to ..

    to check for mail sending - go to SBWP --> create a test mail ---> input your mail ID as the receipint and then send it

    Check in SOST --> if you are seeing the mail..

    Thanks


    Rishi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2014 at 11:11 AM

    Hi ,

    Use the following code:

    DATA : obj_mime_helper TYPE REF TO cl_gbt_multirelated_service ,
    obj_bcs TYPE REF TO cl_bcs ,
    obj_doc_bcs TYPE REF TO cl_document_bcs ,
    obj_recipient TYPE REF TO if_recipient_bcs ,

    w_status TYPE bcs_rqst ,

    is_soli TYPE soli ,

    it_soli TYPE TABLE OF soli , " Body of the mail
    it_html TYPE html_table , " the result of the report in HTML
    it_listobj TYPE table_abaplist , " the result of a report

    obj_sender TYPE REF TO if_sender_bcs .

    PARAMETERS p_prog TYPE syrepid default 'Z_REPORT_PROGRAM'.

    SUBMIT (p_prog) VIA SELECTION-SCREEN AND RETURN EXPORTING LIST TO MEMORY.

    *Catch the memory of the report result.
    CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    listobject = it_listobj
    EXCEPTIONS
    not_found = 1
    OTHERS = 2.

    * Transform the report result in HTML format
    CALL FUNCTION 'WWW_HTML_FROM_LISTOBJECT'
    TABLES
    html = it_html
    listobject = it_listobj.

    * Put the HTML into the table of the mail.
    it_soli = it_html.

    * Create the main object of the mail.
    CREATE OBJECT obj_mime_helper.

    * Set the HTML body of the mail
    CALL METHOD obj_mime_helper->set_main_html
    EXPORTING
    content = it_soli
    filename = ''
    description = 'Hello world'.

    * Set the subject of the mail.
    obj_doc_bcs = cl_document_bcs=>create_from_multirelated(
    i_subject = 'Mail example'
    i_importance = '9' " 1 / 5 / 9
    i_multirel_service = obj_mime_helper ).
    obj_bcs = cl_bcs=>create_persistent( ).
    obj_bcs->set_document(
    i_document = obj_doc_bcs ).

    * Set the email address
    obj_recipient = cl_cam_address_bcs=>create_internet_address(
    i_address_string = 'Test@gmail.com' ).
    obj_bcs->add_recipient(
    i_recipient = obj_recipient ).

    * Change the status.
    MOVE 'N' TO w_status.
    CALL METHOD obj_bcs->set_status_attributes
    EXPORTING
    i_requested_status = w_status.

    * Send the mail.
    obj_bcs->send( ).

    * Commit Work.
    IF sy-subrc EQ space.
    COMMIT WORK AND WAIT.
    ELSE.
    ROLLBACK WORK.
    ENDIF.

    BR.
    GIRI

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2014 at 11:13 AM

    Hi Krishna,

    Best option is that put your report to run in backgroud and in the recipient spool put your mail id ,,,,If scot is configured ,,Find the screen below.. AFter finishing it will automatically go to your mail,,But should not be more that 20 MB bydefault

    Regards,

    RK


    mailll.jpg (102.1 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 08, 2014 at 11:14 AM

    Dear Krishna,

    Kindly read it and use this code to send emails....

    **For Auto Mail *** Start ****

    “for contining mail id’s that will be use in recipient
    DATA : BEGIN OF w_zemp_master OCCURS 0.
    INCLUDE STRUCTURE zemp_master .
    DATA : END OF w_zemp_master.

    DATA : v_empid TYPE zpre_travel-lifnr,
    v_belnr type zpre_travel-belnr.

    ************data declaration for email****************

    DATA: ltb_recipients
    TYPE TABLE OF somlreci1.
    DATA: lwa_recipients TYPE somlreci1.

    DATA: BEGIN OF ltb_objbin OCCURS 0.
    INCLUDE STRUCTURE solisti1.
    DATA: END OF ltb_objbin.
    DATA: lwa_doc_chng TYPE sodocchgi1, lw_tab_lines TYPE sy-tabix,
    ltb_objtxt TYPE solisti1 OCCURS 10 WITH HEADER LINE,
    ltb_objpack TYPE sopcklsti1 OCCURS 2 WITH HEADER LINE.

    DATA : v_mindt TYPE zpre_travel_det-frmdt,
    v_maxdt TYPE zpre_travel_det-todat.

    DATA : BEGIN OF it_send OCCURS 0.
    INCLUDE STRUCTURE zsend_mail.
    DATA : END OF it_send.

    **For Auto Mail *** End ****

    ****************email to HOD for Approval*************
    ************data declaration for email****************

    CLEAR: ltb_objbin, ltb_objtxt, ltb_objpack,
    lwa_doc_chng.
    REFRESH: ltb_objbin,ltb_objtxt, ltb_objpack.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    EXPORTING
    input = zpre_travel-lifnr
    IMPORTING
    output = v_empid.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    EXPORTING
    input = v_sanno
    IMPORTING
    output = v_sanno.

    * control data
    lwa_doc_chng-obj_name = 'URGENT'.
    lwa_doc_chng-sensitivty = 'P'.
    lwa_doc_chng-no_change = 'X'.
    lwa_doc_chng-priority = '1'.
    lwa_doc_chng-obj_prio = '1'.
    lwa_doc_chng-obj_langu = sy-langu.
    lwa_doc_chng-no_change = 'X'.

    ****email subject**

    CONCATENATE 'Approval of Sanction no: ' v_sanno INTO lwa_doc_chng-obj_descr.

    *****email body
    CLEAR ltb_objtxt.

    ltb_objtxt = 'Dear Sir,'.
    APPEND ltb_objtxt.
    CLEAR ltb_objtxt.

    DO 2 TIMES.
    CLEAR ltb_objtxt.
    ltb_objtxt = ' '.
    APPEND ltb_objtxt.
    ENDDO.

    ltb_objtxt = 'Kindly Approve my tour and Advance Request. Please find below the details:'.
    APPEND ltb_objtxt.
    CLEAR ltb_objtxt.

    CONCATENATE 'Employee id : ' v_empid ' Employee Name : ' empnam_txt INTO ltb_objtxt SEPARATED BY space.
    APPEND ltb_objtxt.
    CLEAR ltb_objtxt.

    CONCATENATE 'For Approval Pls refer to the Sanction No :-' v_sanno INTO ltb_objtxt SEPARATED BY space.
    APPEND ltb_objtxt.
    CLEAR ltb_objtxt.

    DO 2 TIMES.
    CLEAR ltb_objtxt.
    ltb_objtxt = ' '.
    APPEND ltb_objtxt.
    ENDDO.
    CLEAR ltb_objtxt.
    ltb_objtxt = 'Thanks & Regards,'.
    APPEND ltb_objtxt.

    CLEAR ltb_objtxt.
    ltb_objtxt = empnam_txt.
    APPEND ltb_objtxt.

    ****email packing
    CLEAR ltb_objtxt.
    DESCRIBE TABLE ltb_objtxt LINES lw_tab_lines.
    IF lw_tab_lines GT 0.
    READ TABLE ltb_objtxt INDEX lw_tab_lines.
    lwa_doc_chng-doc_size = ( lw_tab_lines - 1 ) * 255 + STRLEN( ltb_objtxt ).
    CLEAR ltb_objpack-transf_bin.
    ltb_objpack-body_start = 1.
    ltb_objpack-head_start = 1.
    ltb_objpack-head_num = 0.
    ltb_objpack-body_num = lw_tab_lines.
    ltb_objpack-doc_type = 'RAW'.
    ltb_objpack-transf_bin = space.
    APPEND ltb_objpack.
    ENDIF.

    *recipients
    CLEAR : w_zemp_master,w_zemp_master[].
    REFRESH : w_zemp_master,w_zemp_master[].
    SELECT * INTO TABLE w_zemp_master FROM zemp_master
    WHERE etype EQ 'US'
    AND empid EQ v_empid.

    READ TABLE w_zemp_master INDEX 1.

    IF sy-subrc EQ 0.
    CLEAR lwa_recipients.
    lwa_recipients-rec_type = 'U'.

    lwa_recipients-receiver = w_zemp_master-hodemail.

    APPEND lwa_recipients TO ltb_recipients.

    CLEAR lwa_recipients.
    lwa_recipients-rec_type = 'U'.
    lwa_recipients-copy = 'X'.
    lwa_recipients-receiver = w_zemp_master-email.


    ** IF zemp_master-etype EQ 'HOD'.
    ** CLEAR lwa_recipients.
    ** lwa_recipients-rec_type = 'U'.
    **
    ** lwa_recipients-receiver = w_final_user-mlemail.
    **
    ** APPEND lwa_recipients TO ltb_recipients.
    **
    *** CLEAR lwa_recipients.
    *** lwa_recipients-rec_type = 'U'.
    *** lwa_recipients-copy = 'X'.
    *** lwa_recipients-receiver = zemp_master-email.
    ***
    *** APPEND lwa_recipients TO ltb_recipients.
    **
    ** ENDIF.

    ****sends email
    *call the function to send the pdf file by email
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = lwa_doc_chng
    put_in_outbox = 'X'
    commit_work = 'X'
    TABLES
    packing_list = ltb_objpack
    * contents_bin = t_solisti1
    contents_txt = ltb_objtxt
    receivers = ltb_recipients
    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 EQ '0'.
    COMMIT WORK.
    CLEAR:w_zemp_master.
    MESSAGE 'Your Email has been sent to corresponding authority' TYPE 'I'.

    ENDIF.
    *********end of Email***********************************

    ***********************End of email********************
    MESSAGE 'Sanction No Saved!' TYPE 'S'.

    ENDIF.



    Many Thanks / Himanshu gupta

    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.