Application Development and Automation 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: 
Read only

email functtion module

Former Member
0 Likes
972

Hi friends,

can any one tell me what is the function module to send the email through program.

cheers

uday

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
944

*Send mail.

CALL FUNCTION 'SO_OBJECT_SEND'

EXPORTING

OBJECT_HD_CHANGE = OHDCHANGE

OBJECT_TYPE = 'RAW'

OUTBOX_FLAG = 'X'

OWNER = 'BATCHADM'

ORIGINATOR = G_SENDER

ORIGINATOR_TYPE = 'U'

TABLES

OBJCONT = OCONT

OBJHEAD = OHEAD

RECEIVERS = ORECEIVERS

EXCEPTIONS

ACTIVE_USER_NOT_EXIST = 1

COMMUNICATION_FAILURE = 2

COMPONENT_NOT_AVAILABLE = 3

FOLDER_NOT_EXIST = 4

FOLDER_NO_AUTHORIZATION = 5

FORWARDER_NOT_EXIST = 6

NOTE_NOT_EXIST = 7

OBJECT_NOT_EXIST = 8

OBJECT_NOT_SENT = 9

OBJECT_NO_AUTHORIZATION = 10

OBJECT_TYPE_NOT_EXIST = 11

OPERATION_NO_AUTHORIZATION = 12

OWNER_NOT_EXIST = 13

PARAMETER_ERROR = 14

SUBSTITUTE_NOT_ACTIVE = 15

SUBSTITUTE_NOT_DEFINED = 16

SYSTEM_FAILURE = 17

TOO_MUCH_RECEIVERS = 18

USER_NOT_EXIST = 19

ORIGINATOR_NOT_EXIST = 20

X_ERROR = 21

OTHERS = 22.

7 REPLIES 7
Read only

Former Member
0 Likes
945

*Send mail.

CALL FUNCTION 'SO_OBJECT_SEND'

EXPORTING

OBJECT_HD_CHANGE = OHDCHANGE

OBJECT_TYPE = 'RAW'

OUTBOX_FLAG = 'X'

OWNER = 'BATCHADM'

ORIGINATOR = G_SENDER

ORIGINATOR_TYPE = 'U'

TABLES

OBJCONT = OCONT

OBJHEAD = OHEAD

RECEIVERS = ORECEIVERS

EXCEPTIONS

ACTIVE_USER_NOT_EXIST = 1

COMMUNICATION_FAILURE = 2

COMPONENT_NOT_AVAILABLE = 3

FOLDER_NOT_EXIST = 4

FOLDER_NO_AUTHORIZATION = 5

FORWARDER_NOT_EXIST = 6

NOTE_NOT_EXIST = 7

OBJECT_NOT_EXIST = 8

OBJECT_NOT_SENT = 9

OBJECT_NO_AUTHORIZATION = 10

OBJECT_TYPE_NOT_EXIST = 11

OPERATION_NO_AUTHORIZATION = 12

OWNER_NOT_EXIST = 13

PARAMETER_ERROR = 14

SUBSTITUTE_NOT_ACTIVE = 15

SUBSTITUTE_NOT_DEFINED = 16

SYSTEM_FAILURE = 17

TOO_MUCH_RECEIVERS = 18

USER_NOT_EXIST = 19

ORIGINATOR_NOT_EXIST = 20

X_ERROR = 21

OTHERS = 22.

Read only

Former Member
0 Likes
944

Hi Uday,

Please use this FM

SO_NEW_DOCUMENT_ATT_SEND_API1 to send through programe or if want to send through TCODE its SBWP.

cheers

Mohinder Singh Chauhan

Read only

Former Member
0 Likes
944

Hi,

Use SO_OBJECT_SEND.

Award points if useful...

Read only

Former Member
0 Likes
944

Use the FM SO_DOCUMENT_SEND_API1

Read only

Former Member
0 Likes
944

SO_NEW_DOCUMENT_ATT_SEND_API1 use this and fill all the parameters accordingly,this should work for u.

Read only

Former Member
0 Likes
944

Use Function Module - SO_NEW_DOCUMENT_ATT_SEND_API1

This function module enables you send a new document including any

existing attachments. The document and the attachments are transferred

in the same table. They are created when sent and can also be placed in

the sender's outbox.

It is necessary to distinguish between the document and its folder entries. The document itself only exists in the database once. It is a template for the folder entries and can be addressed via its object ID.

Any number of folder entries can belong to the document. The folder entries contain the attributes of the document as well as some additional attributes relating to the folder entry itself. (Send priority and expiry date of the entry, for example.) Folder entries are created when a document is resubmitted, referenced or sent as well as when a new document is created.

Check the documentation for more details.

Regards

Vinayak

Read only

Former Member
0 Likes
944

Hi ,

1.

Use SO_NEW_DOCUMENT_ATT_SEND_API1 function module and see the function module documentation .

You can come to know what to do with that .

2.

Have a look at this sample program .Example.

&----


*& Report ZVENKAT_EMAIL

*&

&----


*&

*&

&----


REPORT zvenkat_email.

----


  • Variables

----


  • Variables

DATA :

g_sent_to_all TYPE sonv-flag,

g_tab_lines TYPE i,

g_doc_size TYPE i,

off TYPE i,

g_head_desc TYPE string,

g_body_desc TYPE string.

  • Workareas

DATA :

w_subject_data TYPE sodocchgi1,

w_packing_list TYPE sopcklsti1,

w_receivers TYPE somlreci1,

w_object_header TYPE solisti1,

w_contents_bin TYPE solisti1,

w_contents_txt TYPE solisti1,

w_contents_hex TYPE solix,

w_object_parb TYPE soparbi1.

  • w_zess_l_history TYPE zess_l_history.

  • Internal Tables

DATA :

i_subject_data LIKE STANDARD TABLE OF w_subject_data ,

i_packing_list LIKE STANDARD TABLE OF w_packing_list ,

i_receivers LIKE STANDARD TABLE OF w_receivers ,

i_object_header LIKE STANDARD TABLE OF w_object_header,

i_contents_bin LIKE STANDARD TABLE OF w_contents_bin,

i_contents_txt LIKE STANDARD TABLE OF w_contents_txt,

i_contents_hex LIKE STANDARD TABLE OF w_contents_hex,

i_object_parb LIKE STANDARD TABLE OF w_object_parb .

CONSTANTS :

c_subtype(4) TYPE c VALUE '9LNA'.

----


  • selection-screen

----


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text_001.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 2(10) text_002 FOR FIELD email_id.

SELECTION-SCREEN POSITION 18.

PARAMETERS : email_id TYPE text1000 OBLIGATORY.

SELECTION-SCREEN COMMENT 68(50) text_006.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 2(10) text_003 FOR FIELD subject.

SELECTION-SCREEN POSITION 18.

PARAMETERS : subject TYPE text50.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN SKIP.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 2(15) text_004 FOR FIELD mes_bod1.

SELECTION-SCREEN POSITION 18.

PARAMETERS : mes_bod1 TYPE text1000.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 18.

PARAMETERS : mes_bod2 TYPE text1000.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 18.

PARAMETERS : mes_bod3 TYPE text1000.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 18.

PARAMETERS : mes_bod4 TYPE text1000.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 18.

PARAMETERS : mes_bod5 TYPE text1000.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 18.

PARAMETERS : mes_bod6 TYPE text1000.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 18.

PARAMETERS : mes_bod7 TYPE text1000.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 18.

PARAMETERS : mes_bod8 TYPE text1000.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 65.

PARAMETERS: thank_u TYPE text15 DEFAULT 'Thank you,'.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 53(12) text_005 FOR FIELD ur_add1.

SELECTION-SCREEN POSITION 65.

PARAMETERS :ur_add1 TYPE text50.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 65.

PARAMETERS :ur_add2 TYPE text50.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 65.

PARAMETERS :ur_add3 TYPE text50.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 65.

PARAMETERS :ur_add4 TYPE text50.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 65.

PARAMETERS :ur_add5 TYPE text50.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK b1.

----


  • Initialization.

----


INITIALIZATION.

text_001 = 'Mail Sending'.

text_002 = 'Email-ID '.

text_003 = 'Subject '.

text_004 = 'Mail Message '.

text_005 = 'Your Address'.

text_006 = 'Multiple Receivers are possible with COMMA'.

----


  • start-of-selection.

----


START-OF-SELECTION.

CLEAR :

g_sent_to_all ,

g_tab_lines ,

g_doc_size ,

w_subject_data ,

w_packing_list ,

w_receivers ,

w_object_header,

w_contents_bin ,

w_contents_txt ,

w_contents_hex ,

w_object_parb ,

i_subject_data ,

i_packing_list ,

i_receivers ,

i_object_header,

i_contents_bin ,

i_contents_txt ,

i_contents_hex ,

i_object_parb,

g_head_desc,

g_body_desc.

  • Subject of the mail.

w_subject_data-obj_name = 'MAIL_TO_HEAD'.

w_subject_data-obj_descr = subject.

  • Body of the mail

w_contents_txt = space.

APPEND w_contents_txt TO i_contents_txt.

CLEAR w_contents_txt.

DO 8 TIMES.

CASE sy-index.

WHEN 1.

w_contents_txt = mes_bod1.

WHEN 2.

w_contents_txt = mes_bod2.

WHEN 3.

w_contents_txt = mes_bod3.

WHEN 4.

w_contents_txt = mes_bod4.

WHEN 5.

w_contents_txt = mes_bod5.

WHEN 6.

w_contents_txt = mes_bod6.

WHEN 7.

w_contents_txt = mes_bod7.

WHEN 8.

w_contents_txt = mes_bod8.

ENDCASE.

IF w_contents_txt IS NOT INITIAL.

APPEND w_contents_txt TO i_contents_txt.

CLEAR w_contents_txt.

CLEAR g_body_desc.

ENDIF.

ENDDO.

DO 7 TIMES.

CASE sy-index.

WHEN 1.

w_contents_txt = '..............'.

WHEN 2.

w_contents_txt = thank_u.

WHEN 3.

w_contents_txt = ur_add1.

WHEN 4.

w_contents_txt = ur_add2.

WHEN 5.

w_contents_txt = ur_add3.

WHEN 6.

w_contents_txt = ur_add4.

WHEN 7.

w_contents_txt = ur_add5.

ENDCASE.

IF w_contents_txt IS NOT INITIAL.

APPEND w_contents_txt TO i_contents_txt.

CLEAR w_contents_txt.

CLEAR g_body_desc.

ENDIF.

ENDDO.

  • Write Packing List (Body)

DESCRIBE TABLE i_contents_txt LINES g_tab_lines.

READ TABLE i_contents_txt INTO w_contents_txt INDEX g_tab_lines.

w_subject_data-doc_size = ( g_tab_lines - 1 ) * 255 + STRLEN(

w_contents_txt ).

CLEAR w_packing_list-transf_bin.

w_packing_list-head_start = 1.

w_packing_list-head_num = 0.

w_packing_list-body_start = 1.

w_packing_list-body_num = g_tab_lines.

w_packing_list-doc_type = 'RAW'.

APPEND w_packing_list TO i_packing_list.

CLEAR w_packing_list.

  • Receivers List.

DO.

FIND ',' IN email_id MATCH OFFSET off.

w_receivers-rec_type = 'U'.

IF off NE 0.

w_receivers-receiver = email_id+0(off).

off = off + 1.

CLEAR:email_id+0(off).

SHIFT email_id LEFT BY off PLACES.

ELSE.

w_receivers-receiver = email_id.

CLEAR email_id.

ENDIF.

APPEND w_receivers TO i_receivers .

CLEAR:w_receivers,

off.

IF email_id IS INITIAL.

EXIT.

ENDIF.

ENDDO.

  • Function module to send mail to Recipients

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = w_subject_data

put_in_outbox = 'X'

commit_work = 'X'

IMPORTING

sent_to_all = g_sent_to_all

TABLES

packing_list = i_packing_list

object_header = i_object_header

contents_bin = i_contents_bin

contents_txt = i_contents_txt

receivers = i_receivers

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 = 0 .

MESSAGE i303(me) WITH 'Mail has been Successfully Sent!'.

ENDIF.

I think that helps you .

Reagards,

Venkat.O