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: 

sending mail to gmail address

former_member424229
Participant
0 Kudos

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.

8 REPLIES 8

Former Member
0 Kudos

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

0 Kudos

Hi Lakshmi,

Thanks for response.

Actually I am new to abap. I want to know the procedure for sending mails to the domain like gmail.com and to the company domain. you have any documentation on this please provide me.

0 Kudos

Hi,

ask your system administrator to check if the SCOT trans. is configure ton send mail only for specific domain or for all

regards

Fred

Sending Mail using Oo

0 Kudos

Hi Krishna

Please search on SCN for the same. SCOT configuration needs to be maintained.

Nabheet

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

himanshu_gupta13
Employee
Employee
0 Kudos

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