Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

FM to send text message external email (without any attachments)

Hi Guys,

Can somebody tell me the function module and share the code to send simple text message email to external email.



Former Member
Former Member replied


Try the following code

DATA: doc_chng       LIKE sodocchgi1,
      subject(6)     TYPE c VALUE 'test',
      reclist        LIKE somlreci1  OCCURS 5 WITH HEADER LINE,
      line(87)       TYPE c,
      objtxt         LIKE solisti1   OCCURS 10 WITH HEADER LINE,
      tab_lines      LIKE sy-tabix,
      objpack        LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE,
      sender_address LIKE soextreci1-receiver.

doc_chng-obj_name   = sy-title.
doc_chng-obj_descr  = subject.

reclist-receiver  = 'email address in the format'. " Put email address here
reclist-rec_type  = 'U'.
APPEND reclist.

* You can add more receivers to the same table

line = 'This is a test email for checking if the external email is working or not'.
WRITE line TO objtxt.
APPEND objtxt.

CLEAR line.
WRITE line TO objtxt.
APPEND objtxt.

line = 'All the best with email from R/3'.
WRITE line TO objtxt.
APPEND objtxt.
CLEAR  line.
CLEAR  objtxt.
line = '-----------------------------------------------------------------'.
WRITE line TO objtxt.
APPEND objtxt.

DESCRIBE TABLE objtxt LINES tab_lines.

READ TABLE objtxt INDEX tab_lines.
sy-subrc = 0.
doc_chng-doc_size  = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).

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.

sender_address = 'email address in the format'.

    document_data              = doc_chng
    sender_address             = sender_address       "EMAIL_FR
    sender_address_type        = 'INT'
    commit_work                = 'X'
    packing_list               = objpack
    contents_txt               = objtxt
    receivers                  = reclist
    too_many_receivers         = 1
    document_not_sent          = 2
    operation_no_authorization = 4
    OTHERS                     = 99.



0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question