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 Email to personal mail ID

Former Member
0 Kudos

hi people...

1.I want to know if there are any Function Modules for triggering text mail to my personal non sap email id from SAP R/3 without any configurations.

2. Is any basic configuration mandatory?

Regards,

Rakesh

1 ACCEPTED SOLUTION

former_member181962
Active Contributor
0 Kudos

Hi rakesh,

The FM SO_NEW_DOCUMENT_SEND_API1 would do the same for you, the only thing is that RECLIST-REC_TYPE should be 'U'.

Example in the document:

Example

Sending a confidential RAW document to an internal user and an Internet address. The new document is also placed in the sender's outbox.

DATA: OBJCONT LIKE SOLISTI1 OCCURS 5 WITH HEADER LINE.

DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.

DATA: DOC_CHNG LIKE SODOCCHGI1.

DATA: ENTRIES LIKE SY-TABIX.

DATA: NAME(15).

  • Fill the document

DOC_CHNG-OBJ_NAME = 'URGENT'.

DOC_CHNG-OBJ_DESCR = 'Read at once !'.

DOC_CHNG-SENSITIVTY = 'P'.

OBJCONT = 'Hey guys, time for lunch !!!'.

APPEND OBJCONT.

OBJCONT = 'Lets get going !'.

APPEND OBJCONT.

DESCRIBE TABLE OBJCONT LINES ENTRIES.

READ TABLE OBJCONT INDEX ENTRIES.

DOC_CHNG-DOC_SIZE = ( ENTRIES - 1 ) * 255 + STRLEN( OBJCONT ).

  • Fill the receiver list

CLEAR RECLIST.

RECLIST-RECEIVER = SY-UNAME. " replace with <login name>

RECLIST-REC_TYPE = 'B'.

RECLIST-EXPRESS = 'X'.

APPEND RECLIST.

CLEAR RECLIST.

RECLIST-RECEIVER = 'ned.neighbour@next.door.com'.

RECLIST-REC_TYPE = 'U'.

APPEND RECLIST.

  • Send the document

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

DOCUMENT_TYPE = 'RAW'

DOCUMENT_DATA = DOC_CHNG

PUT_IN_OUTBOX = 'X'

TABLES

OBJECT_CONTENT = OBJCONT

RECEIVERS = RECLIST

EXCEPTIONS

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

OPERATION_NO_AUTHORIZATION = 4

OTHERS = 99.

CASE SY-SUBRC.

WHEN 0.

LOOP AT RECLIST.

IF RECLIST-RECEIVER = SPACE.

NAME = RECLIST-REC_ID.

ELSE.

NAME = RECLIST-RECEIVER.

ENDIF.

IF RECLIST-RETRN_CODE = 0.

WRITE: / NAME, ': succesfully sent'.

ELSE.

WRITE: / NAME, ': error occured'.

ENDIF.

ENDLOOP.

WHEN 1.

WRITE: / 'Too many receivers specified !'.

WHEN 2.

WRITE: / 'No receiver got the document !'.

WHEN 4.

WRITE: / 'Missing send authority !'.

WHEN OTHERS.

WRITE: / 'Unexpected error occurred !'.

ENDCASE.

REgards,

Ravi

6 REPLIES 6

vinod_gunaware2
Active Contributor
0 Kudos

Very often, users would like to have the ability to send their SAP reports via the company email system. This abap send mail program will help you to achieve this. Whether you can send an external mail via SAP will depends whether your SAP system have been configured and link to the external mail server like MS Exchange or Lotus notes.

REPORT ZSENDEXTERNAL.

DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.

DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.

DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.

DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.

DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.

DATA: DOC_CHNG LIKE SODOCCHGI1.

DATA: TAB_LINES LIKE SY-TABIX.

  • Creation of the document to be sent

  • File Name

DOC_CHNG-OBJ_NAME = 'SENDFILE'.

  • Mail Subject

DOC_CHNG-OBJ_DESCR = 'Send External Mail'.

  • Mail Contents

OBJTXT = 'Minimum bid : $250000'.

APPEND OBJTXT.

OBJTXT = 'A representation of the pictures up for auction'.

APPEND OBJTXT.

OBJTXT = 'was included as attachment.'.

APPEND OBJTXT.

DESCRIBE TABLE OBJTXT LINES TAB_LINES.

READ TABLE OBJTXT INDEX TAB_LINES.

DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).

  • Creation of the entry for the compressed document

CLEAR OBJPACK-TRANSF_BIN.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 0.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = TAB_LINES.

OBJPACK-DOC_TYPE = 'RAW'.

APPEND OBJPACK.

  • Creation of the document attachment

  • (Assume that the data in OBJBIN is in BMP format)

*OBJBIN = ' \O/ '. APPEND OBJBIN.

*OBJBIN = ' | '. APPEND OBJBIN.

*OBJBIN = ' / \ '. APPEND OBJBIN.

*DESCRIBE TABLE OBJBIN LINES TAB_LINES.

*OBJHEAD = 'PICTURE.BMP'.

*APPEND OBJHEAD.

    • Creation of the entry for the compressed attachment

*OBJPACK-TRANSF_BIN = 'X'.

*OBJPACK-HEAD_START = 1.

*OBJPACK-HEAD_NUM = 1.

*OBJPACK-BODY_START = 1.

*OBJPACK-BODY_NUM = TAB_LINES.

*OBJPACK-DOC_TYPE = 'BMP'.

*OBJPACK-OBJ_NAME = 'PICTURE'.

*OBJPACK-OBJ_DESCR = 'Representation of object 138'.

*OBJPACK-DOC_SIZE = TAB_LINES * 255.

*APPEND OBJPACK.

  • Completing the recipient list

RECLIST-RECEIVER = 'youremail@sap.com'.

RECLIST-REC_TYPE = 'U'.

APPEND RECLIST.

*RECLIST-RECEIVER = 'SAPUSERNAME'.

*RECLIST-REC_TYPE = 'P'.

*APPEND RECLIST.

  • Sending the document

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = DOC_CHNG

PUT_IN_OUTBOX = 'X'

TABLES

PACKING_LIST = OBJPACK

OBJECT_HEADER = OBJHEAD

CONTENTS_BIN = OBJBIN

CONTENTS_TXT = OBJTXT

RECEIVERS = RECLIST

EXCEPTIONS

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

OPERATION_NO_AUTHORIZATION = 4

OTHERS = 99.

CASE SY-SUBRC.

WHEN 0.

WRITE: / 'Result of the send process:'.

LOOP AT RECLIST.

WRITE: / RECLIST-RECEIVER(48), ':'.

IF RECLIST-RETRN_CODE = 0.

WRITE 'The document was sent'.

ELSE.

WRITE 'The document could not be sent'.

ENDIF.

ENDLOOP.

WHEN 1.

WRITE: / 'No authorization for sending to the specified number',

'of recipients'.

WHEN 2.

WRITE: / 'Document could not be sent to any recipient'.

WHEN 4.

WRITE: / 'No send authorization'.

WHEN OTHERS.

WRITE: / 'Error occurred while sending'.

ENDCASE.

USE <b>SCOT</b> setting also

regards

vinod

Former Member
0 Kudos

hi,

check this FM SO_NEW_DOCUMENT_SEND_API1, which is used to send the mail to your non-sap mail Id.

you will have a very good documentatio for the same.

sample code :

TABLES : ZVW_ID_EXPIRY.

DATA: BEGIN OF I_USERS OCCURS 0,

NAME(12) TYPE C,

END OF I_USERS.

DATA: T_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE.

DATA: T_OBJCONT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.

DATA: S_DOC_CHNG LIKE SODOCCHGI1,

V_SUBJ(255) TYPE C,

V_LINE(255) TYPE C.

  • Mail IDs

T_RECLIST-RECEIVER = 'usabarin@yahoo.com'.

T_RECLIST-REC_TYPE = 'U'.

APPEND T_RECLIST.

  • Send Mail

  • Subject

CONCATENATE 'Alert: Notification changed'

'Creation' INTO V_SUBJ SEPARATED BY SPACE.

S_DOC_CHNG-OBJ_NAME = V_SUBJ.

S_DOC_CHNG-OBJ_DESCR = V_SUBJ.

S_DOC_CHNG-SENSITIVTY = 'P'.

  • Body

T_OBJCONT-LINE ='Dear Sir,'.

APPEND T_OBJCONT.

T_OBJCONT-LINE = SPACE.

APPEND T_OBJCONT.

CONCATENATE ' Notification has been changed' 'Mani'

INTO V_LINE SEPARATED BY SPACE.

T_OBJCONT-LINE = V_LINE..

APPEND T_OBJCONT.

CONCATENATE ' Kindly take neccessary actions to get'

'the work done at the earliest.'

INTO V_LINE SEPARATED BY SPACE.

T_OBJCONT-LINE = V_LINE..

APPEND T_OBJCONT.

T_OBJCONT-LINE = SPACE.

APPEND T_OBJCONT.

T_OBJCONT-LINE = 'Regards,'.

APPEND T_OBJCONT.

T_OBJCONT-LINE = 'SAP WorkFlow.'.

APPEND T_OBJCONT.

T_OBJCONT-LINE = SPACE.

APPEND T_OBJCONT.

CONCATENATE 'NB: This is a system generated message,'

'Donot reply to this mail.'

INTO V_LINE SEPARATED BY SPACE.

T_OBJCONT-LINE = V_LINE..

APPEND T_OBJCONT.

  • Send Mail Function

IF NOT T_RECLIST[] IS INITIAL.

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

DOCUMENT_DATA = S_DOC_CHNG

DOCUMENT_TYPE = 'RAW'

  • put_in_outbox = ' '

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

TABLES

  • object_header = t_objhead

OBJECT_CONTENT = T_OBJCONT

  • CONTENTS_HEX =

  • OBJECT_PARA =

  • OBJECT_PARB =

RECEIVERS = T_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

.

ENDIF.

Rgds.

Sabari

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

As far I know you need configuration.

Check the following link:-

/people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface

http://help.sap.com/saphelp_nw04/helpdata/en/2b/d925bf4b8a11d1894c0000e8323c4f/frameset.htm

these link will help u to config SCOT.

And one more thing u have to do..

Go to SE11 n open Table sxnodes in change mode.

And change F_ESMTP field to false i.e. BLANK for the Field NODE = SMTP.\

Check these links for code samples for sending mail.

http://www.sap-img.com/fu016.htm

http://www.geocities.com/mpioud/Z_EMAIL_ABAP_REPORT.html

http://www.thespot4sap.com/Articles/SAP_Mail_SO_Object_Send.asp

Kindly reward points if it helps.

Former Member
0 Kudos

HI

you have to use 'SO_OBJECT_SEND' for sending external mails

REPORT ZREPORT_TO_EMAIL NO STANDARD PAGE HEADING LINE-SIZE 200.

DATA : BEGIN OF ITAB OCCURS 0,

PERNR LIKE PA0001-PERNR,

ENAME LIKE PA0001-ENAME,

END OF ITAB.

DATA: message_content LIKE soli OCCURS 10 WITH HEADER LINE,

receiver_list LIKE soos1 OCCURS 5 WITH HEADER LINE,

packing_list LIKE soxpl OCCURS 2 WITH HEADER LINE,

listobject LIKE abaplist OCCURS 10,

compressed_attachment LIKE soli OCCURS 100 WITH HEADER LINE,

w_object_hd_change LIKE sood1,

compressed_size LIKE sy-index.

START-OF-SELECTION.

SELECT PERNR ENAME

INTO CORRESPONDING FIELDS OF TABLE ITAB

FROM PA0001

WHERE PERNR < 50.

LOOP AT ITAB.

WRITE :/02 SY-VLINE , ITAB-PERNR, 15 SY-VLINE , ITAB-ENAME, 50

SY-VLINE.

ENDLOOP.

  • Receivers

<b>receiver_list-recextnam = 'shari_kishore84@yahoo.com'.</b>

  • EMAIL ADDRESS

RECEIVER_list-RECESC = 'E'. "<-

RECEIVER_list-SNDART = 'INT'."<-

RECEIVER_list-SNDPRI = '1'."<-

APPEND receiver_list.

  • General data

w_object_hd_change-objla = sy-langu.

w_object_hd_change-objnam = 'Object name'.

w_object_hd_change-objsns = 'P'.

  • Mail subject

w_object_hd_change-objdes = 'Message subject'.

  • Mail body

APPEND 'Message content' TO message_content.

  • Attachment

CALL FUNCTION 'SAVE_LIST'

EXPORTING

list_index = '0'

TABLES

listobject = listobject.

CALL FUNCTION 'TABLE_COMPRESS'

IMPORTING

compressed_size = compressed_size

TABLES

in = listobject

out = compressed_attachment.

DESCRIBE TABLE compressed_attachment.

CLEAR packing_list.

packing_list-transf_bin = 'X'.

packing_list-head_start = 0.

packing_list-head_num = 0.

packing_list-body_start = 1.

packing_list-body_num = sy-tfill.

packing_list-objtp = 'ALI'.

packing_list-objnam = 'Object name'.

packing_list-objdes = 'Attachment description'.

packing_list-objlen = compressed_size.

APPEND packing_list.

CALL FUNCTION 'SO_OBJECT_SEND'

EXPORTING

object_hd_change = w_object_hd_change

object_type = 'RAW'

owner = sy-uname

TABLES

objcont = message_content

receivers = receiver_list

packing_list = packing_list

att_cont = compressed_attachment.

regards

kishore

former_member181962
Active Contributor
0 Kudos

Hi rakesh,

The FM SO_NEW_DOCUMENT_SEND_API1 would do the same for you, the only thing is that RECLIST-REC_TYPE should be 'U'.

Example in the document:

Example

Sending a confidential RAW document to an internal user and an Internet address. The new document is also placed in the sender's outbox.

DATA: OBJCONT LIKE SOLISTI1 OCCURS 5 WITH HEADER LINE.

DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.

DATA: DOC_CHNG LIKE SODOCCHGI1.

DATA: ENTRIES LIKE SY-TABIX.

DATA: NAME(15).

  • Fill the document

DOC_CHNG-OBJ_NAME = 'URGENT'.

DOC_CHNG-OBJ_DESCR = 'Read at once !'.

DOC_CHNG-SENSITIVTY = 'P'.

OBJCONT = 'Hey guys, time for lunch !!!'.

APPEND OBJCONT.

OBJCONT = 'Lets get going !'.

APPEND OBJCONT.

DESCRIBE TABLE OBJCONT LINES ENTRIES.

READ TABLE OBJCONT INDEX ENTRIES.

DOC_CHNG-DOC_SIZE = ( ENTRIES - 1 ) * 255 + STRLEN( OBJCONT ).

  • Fill the receiver list

CLEAR RECLIST.

RECLIST-RECEIVER = SY-UNAME. " replace with <login name>

RECLIST-REC_TYPE = 'B'.

RECLIST-EXPRESS = 'X'.

APPEND RECLIST.

CLEAR RECLIST.

RECLIST-RECEIVER = 'ned.neighbour@next.door.com'.

RECLIST-REC_TYPE = 'U'.

APPEND RECLIST.

  • Send the document

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

DOCUMENT_TYPE = 'RAW'

DOCUMENT_DATA = DOC_CHNG

PUT_IN_OUTBOX = 'X'

TABLES

OBJECT_CONTENT = OBJCONT

RECEIVERS = RECLIST

EXCEPTIONS

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

OPERATION_NO_AUTHORIZATION = 4

OTHERS = 99.

CASE SY-SUBRC.

WHEN 0.

LOOP AT RECLIST.

IF RECLIST-RECEIVER = SPACE.

NAME = RECLIST-REC_ID.

ELSE.

NAME = RECLIST-RECEIVER.

ENDIF.

IF RECLIST-RETRN_CODE = 0.

WRITE: / NAME, ': succesfully sent'.

ELSE.

WRITE: / NAME, ': error occured'.

ENDIF.

ENDLOOP.

WHEN 1.

WRITE: / 'Too many receivers specified !'.

WHEN 2.

WRITE: / 'No receiver got the document !'.

WHEN 4.

WRITE: / 'Missing send authority !'.

WHEN OTHERS.

WRITE: / 'Unexpected error occurred !'.

ENDCASE.

REgards,

Ravi

former_member927251
Active Contributor
0 Kudos

Hi Rakesh,

You can create a function module of your own with the following code in it. Use this function module to send an email to your personal mail id.

Please reward some points if it helps you.

Regards,

Amit M. Mishra

FUNCTION z_e_keg_send_simple_email.

*"----


""Local interface:

*" IMPORTING

*" VALUE(REQUESTED_STATUS) TYPE BCS_RQST DEFAULT 'E'

*" VALUE(DOCUMENTS) TYPE ZES_KEG_EMAIL_DOCUMENTS

*" VALUE(RECIPIENTS) TYPE ZES_KEG_EMAIL_RECIPIENTS

*" RAISING

*" CX_BCS

*"----


----


  • CLASS-DEFINITIONS *

----


DATA: send_request TYPE REF TO cl_bcs.

DATA: document TYPE REF TO cl_document_bcs.

DATA: sender TYPE REF TO cl_sapuser_bcs.

DATA: recipient TYPE REF TO if_recipient_bcs.

DATA: exception_info TYPE REF TO if_os_exception_info,

bcs_exception TYPE REF TO cx_bcs.

----


  • INTERNAL TABLES *

----


DATA: l_mailtext TYPE soli_tab.

DATA: l_mailhex TYPE solix_tab.

DATA: iaddsmtp TYPE bapiadsmtp OCCURS 0 WITH HEADER LINE.

DATA: ireturn TYPE bapiret2 OCCURS 0 WITH HEADER LINE.

----


  • VARIABLES *

----


DATA: mail_line LIKE LINE OF l_mailtext.

DATA: mailx_line LIKE LINE OF l_mailhex.

DATA: bapiadsmtp TYPE bapiadsmtp.

----


  • CONSTANTS *

----


CONSTANTS:

kimball_domain(12) TYPE c VALUE '@kimball.com'.

CLASS cl_cam_address_bcs DEFINITION LOAD.

CLASS cl_abap_char_utilities DEFINITION LOAD.

TRY.

  • Create persistent send request

send_request = cl_bcs=>create_persistent( ).

DATA: first(1) TYPE c.

CLEAR first.

DATA: documents_line LIKE LINE OF documents.

LOOP AT documents INTO documents_line.

IF first IS INITIAL.

MOVE 'X' TO first.

  • Build the Main Document

IF documents_line-content_hex[] IS INITIAL.

document = cl_document_bcs=>create_document(

i_type = documents_line-type

i_text = documents_line-content_text

i_subject = documents_line-subject ).

ELSE.

document = cl_document_bcs=>create_document(

i_type = documents_line-type

i_hex = documents_line-content_hex

i_subject = documents_line-subject ).

ENDIF.

ELSE.

IF documents_line-content_hex[] IS INITIAL.

  • Add Attachment

CALL METHOD document->add_attachment

EXPORTING

i_attachment_type = documents_line-type

i_attachment_subject = documents_line-subject

i_att_content_text = documents_line-content_text.

ELSE.

CALL METHOD document->add_attachment

EXPORTING

i_attachment_type = documents_line-type

i_attachment_subject = documents_line-subject

i_att_content_hex = documents_line-content_hex.

ENDIF.

ENDIF.

ENDLOOP.

  • Add document to send request

CALL METHOD send_request->set_document( document ).

  • Get sender object

sender = cl_sapuser_bcs=>create( sy-uname ).

  • Add sender

CALL METHOD send_request->set_sender

EXPORTING

i_sender = sender.

DATA: recipients_line LIKE LINE OF recipients.

LOOP AT recipients INTO recipients_line.

IF recipients_line-c_address IS INITIAL.

  • Create recipient

CLEAR iaddsmtp.

REFRESH iaddsmtp.

CLEAR bapiadsmtp.

CLEAR recipient.

  • Read the E-Mail address for the user

CALL FUNCTION 'BAPI_USER_GET_DETAIL'

EXPORTING

username = recipients_line-uname

TABLES

return = ireturn

addsmtp = iaddsmtp.

LOOP AT iaddsmtp WHERE std_no = 'X'.

CLEAR bapiadsmtp.

MOVE iaddsmtp TO bapiadsmtp.

ENDLOOP.

  • If no E-mail address was found, create one.

IF bapiadsmtp-e_mail = ''.

CONCATENATE recipients_line-uname kimball_domain

INTO recipients_line-c_address.

ELSE.

MOVE bapiadsmtp-e_mail TO recipients_line-c_address.

ENDIF.

ENDIF.

recipient = cl_cam_address_bcs=>create_internet_address( recipients_line-c_address ).

  • Add recipient with its respective attributes to send request

CALL METHOD send_request->add_recipient

EXPORTING

i_recipient = recipient

i_express = recipients_line-i_express

i_copy = recipients_line-i_copy

i_blind_copy = recipients_line-i_blind_copy

i_no_forward = recipients_line-i_no_foward.

ENDLOOP.

  • Set that you don't need a Return Status E-mail

DATA: status_mail TYPE bcs_stml.

status_mail = requested_status.

CALL METHOD send_request->set_status_attributes

EXPORTING

i_requested_status = requested_status

i_status_mail = status_mail.

  • set send immediately flag

send_request->set_send_immediately( 'X' ).

  • Send document

CALL METHOD send_request->send( ).

COMMIT WORK.

CATCH cx_bcs INTO bcs_exception.

RAISE EXCEPTION bcs_exception.

ENDTRY.

ENDFUNCTION.