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

How to send mail using HTML format using tags

aris_hidalgo
Contributor
0 Likes
426

Hello experts,

I am currently using FM SO_NEW_DOCUMENT_SEND_API1 to send e-mails to our users' Outlook accounts. Now, I converted its document type from 'RAW' to 'HTM'. I enclosed my texts in HTML tags. But the problem is, I cannot see a thing when I check my message in SCOT. It just opens internet explorer and thats it. Anyway, Below is my code:

  • get e-mail addresses of controllers in table ZSHIPTO_EMAIL

SELECT * FROM zshipto_email

INTO TABLE it_zshipto_email

WHERE zevent = '2'.

IF sy-dbcnt > 0.

IF NOT it_del_entries[] IS INITIAL.

CLEAR lv_contents.

maildata-obj_name = 'Record Deleted in table ZTS0001'.

maildata-obj_descr = 'Record Deleted in table ZTS0001'.

maildata-obj_langu = sy-langu.

    • records deleted in ZTS0001 and ZTS_STPGEOLOC

CLEAR: lv_flag, lv_counter.

LOOP AT it_zshipto_email.

CLEAR: it_del_entries, mailtxt.

LOOP AT it_del_entries ASSIGNING <fs_del_entries>.

  • get name of dealer

SELECT SINGLE name1 FROM kna1

INTO <fs_del_entries>-name1

WHERE kunnr = <fs_del_entries>-kunnr.

IF lv_counter IS INITIAL.

CONCATENATE: '<p>'

'FYI: The ff record/s were deleted in tables'

'ZTS0001 and ZTS_STPGEOLOC by user' sy-uname

'</p>'

INTO lv_contents

SEPARATED BY space.

mailtxt-line = lv_contents.

APPEND mailtxt.

CLEAR: mailtxt, lv_contents.

ENDIF.

APPEND mailtxt.

CONCATENATE: '<p>'

'Dealer :' <fs_del_entries>-kunnr '-'

<fs_del_entries>-name1 '</p>'

INTO lv_contents

SEPARATED BY space.

mailtxt-line = lv_contents.

APPEND mailtxt.

CLEAR: mailtxt, lv_contents.

CONCATENATE: '<p>'

'Ship-To:' <fs_del_entries>-cdseq '</p>'

INTO lv_contents

SEPARATED BY space.

mailtxt-line = lv_contents.

APPEND mailtxt.

CLEAR: mailtxt, lv_contents.

CONCATENATE: '<p>'

'Address:' <fs_del_entries>-zaddress '</p>'

INTO lv_contents

SEPARATED BY space.

mailtxt-line = lv_contents.

APPEND mailtxt.

CLEAR: mailtxt, lv_contents.

CONCATENATE: '<p>'

'Contact person:' <fs_del_entries>-zcperson

'</p>'

INTO lv_contents

SEPARATED BY space.

mailtxt-line = lv_contents.

APPEND mailtxt.

CLEAR: mailtxt, lv_contents.

CONCATENATE: '<p>'

'Contact number:' <fs_del_entries>-zcnumber

'</p>'

INTO lv_contents

SEPARATED BY space.

mailtxt-line = lv_contents.

APPEND mailtxt.

CLEAR: mailtxt, lv_contents.

lv_counter = 1.

ENDLOOP.

APPEND mailtxt.

mailrec-receiver = it_zshipto_email-zemail.

mailrec-rec_type = 'U'.

APPEND mailrec.

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = maildata

document_type = 'HTM'

put_in_outbox = 'X'

commit_work = 'X'

TABLES

  • object_header = mailtxt

object_content = mailtxt

receivers = mailrec

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 ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CLEAR: mailtxt, mailrec, lv_counter.

REFRESH: mailtxt, mailrec.

ENDLOOP.

ENDIF.

Message was edited by: viraylab

2 REPLIES 2
Read only

Former Member
Read only

0 Likes
391

Hi guys,

I just need some simple examples based on my code above. Vijay, thanks for the PDF. It will also help a lot.

Regards!