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

Send e-mail in HTML-format with attachment

Former Member
0 Likes
3,407

Does function SO_OBJECT_SEND allow to send e-mail with attachment?

Does function SO_DOCUMENT_SEND_API1 allow to send e-mail in HTML format?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,251

Hi S.S,

yes you can use both of them because SO_DOCUMENT_SEND_API1 used function SO_OBJECT_SEND internally.

but I would recommend you to use CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

  • Sending the document

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = your document data

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = your packing list

object_header = your email header

contents_hex = your attachment

contents_txt = contents

receivers = email receiver

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

OTHERS = 8.

IF sy-subrc EQ 0.

MESSAGE

ENDIF.

this fm allows you send any type of attachment.

hope this helps. cheers

14 REPLIES 14
Read only

Former Member
Read only

GauthamV
Active Contributor
0 Likes
2,251

Use this fm.

SO_DOCUMENT_SEND_API1

Read only

Former Member
0 Likes
2,251

Hi,

[Send email in HTML format|]

Thanks!

Read only

Former Member
0 Likes
2,251

You can use BCS class also for this purpose.

Regards

Sathar

Read only

Former Member
0 Likes
2,251

hi,

the Output is relied on the SCOT tcode settings.

where, you define the type of output to be sent.

Read only

Former Member
0 Likes
2,251
Read only

Former Member
0 Likes
2,251

I am using SO_OBJECT_SEND yet.

How send e-mail with attachments with this function?

There is tables ATT_CONT and ATT_HEAD, how to fill this tables to create attachment?

Read only

Former Member
0 Likes
2,251

Hi ,

This function module will help you in attaching the file in the prescribed format.

1. SO_NEW_DOCUMENT_ATT_SEND_API1.

Good luck,

Varghese.K.Oommen

Read only

Former Member
0 Likes
2,251

Hi,

Kindly go through this link,

Here i have sended 2 attachments to mail id in xls format ,you can change

it to html likewise and rest sample code can be used :

https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/to%252bsend%252b2%252bint%252btables%252bdat...

Hope it helps

Regrds

Mansi

Read only

Former Member
0 Likes
2,251

Yes, but i want to send e-mail with attachnment by SO_OBJECT_SEND.

Read only

Former Member
0 Likes
2,252

Hi S.S,

yes you can use both of them because SO_DOCUMENT_SEND_API1 used function SO_OBJECT_SEND internally.

but I would recommend you to use CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

  • Sending the document

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = your document data

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = your packing list

object_header = your email header

contents_hex = your attachment

contents_txt = contents

receivers = email receiver

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

OTHERS = 8.

IF sy-subrc EQ 0.

MESSAGE

ENDIF.

this fm allows you send any type of attachment.

hope this helps. cheers

Read only

Former Member
0 Likes
2,251

thanks

Edited by: S S on Mar 6, 2009 9:39 AM

Read only

Former Member
0 Likes
2,251

Bu how to send email by 'SO_NEW_DOCUMENT_ATT_SEND_API1' in HTML format?

Read only

0 Likes
2,251

Hi SS

See if you can understand this sample program

PARAMETERS: po_email TYPE AD_SMTPADR LOWER CASE.

DATA: li_objcont TYPE STANDARD TABLE OF solisti1,

li_reclist TYPE STANDARD TABLE OF somlreci1,

li_objpack TYPE STANDARD TABLE OF sopcklsti1,

li_objhead TYPE STANDARD TABLE OF solisti1,

li_content TYPE STANDARD TABLE OF solisti1,

lwa_objcont TYPE solisti1,

lwa_reclist TYPE somlreci1,

lwa_objpack TYPE sopcklsti1,

lwa_objhead TYPE solisti1,

lwa_content TYPE solisti1,

lwa_doc TYPE sodocchgi1,

l_lines TYPE i.

REFRESH: li_objcont[], li_reclist[],

li_objpack[], li_objhead[],

li_content[].

CLEAR: lwa_objcont, lwa_reclist,

lwa_objpack, lwa_objhead,

lwa_content, lwa_doc.

MOVE '<body>' TO lwa_objcont.

APPEND lwa_objcont TO li_objcont.

MOVE '<p>' TO lwa_objcont.

APPEND lwa_objcont TO li_objcont.

MOVE 'This is a sample HTML content from test program' TO lwa_objcont.

APPEND lwa_objcont TO li_objcont.

MOVE '</p>' TO lwa_objcont.

APPEND lwa_objcont TO li_objcont.

MOVE '</body>' TO lwa_objcont.

APPEND lwa_objcont TO li_objcont.

lwa_reclist-receiver = po_email.

lwa_reclist-rec_type = 'U'.

APPEND lwa_reclist TO li_reclist.

lwa_objhead = 'test.htm'.

APPEND lwa_objhead TO li_objhead.

lwa_content = 'Please find attached document for more details'.

APPEND lwa_content TO li_content.

CLEAR l_lines.

DESCRIBE TABLE li_content LINES l_lines.

READ TABLE li_content INTO lwa_content INDEX l_lines.

lwa_doc-doc_size = ( l_lines - 1 ) * 255 + STRLEN( lwa_content ).

lwa_doc-obj_langu = 'E'.

lwa_doc-obj_name = 'Test HTML file'.

lwa_doc-obj_descr = 'Test HTML file'.

CLEAR lwa_objpack-transf_bin.

lwa_objpack-head_start = 1.

lwa_objpack-head_num = 0.

lwa_objpack-body_start = 1.

lwa_objpack-body_num = l_lines.

lwa_objpack-doc_type = 'RAW'.

APPEND lwa_objpack TO li_objpack.

CLEAR: lwa_objpack, l_lines.

DESCRIBE TABLE li_objcont LINES l_lines.

READ TABLE li_objcont INTO lwa_objcont INDEX l_lines.

lwa_objpack-doc_size = ( l_lines - 1 ) * 255 + STRLEN( lwa_objcont ).

lwa_objpack-transf_bin = 'X'.

lwa_objpack-head_start = 1.

lwa_objpack-head_num = 0.

lwa_objpack-body_start = 1.

lwa_objpack-body_num = l_lines.

lwa_objpack-doc_type = 'HTM' .

lwa_objpack-obj_name = 'Test HTML file'.

lwa_objpack-obj_descr = 'Test HTML file'.

APPEND lwa_objpack TO li_objpack.

*Sending the mail

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = lwa_doc

put_in_outbox = 'X'

TABLES

packing_list = li_objpack

object_header = li_objhead

contents_bin = li_objcont

contents_txt = li_content

receivers = li_reclist

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

operation_no_authorization = 4

OTHERS = 99.

IF sy-subrc NE 0.

WRITE:/ 'Document sending failed'.

ELSE.

WRITE:/ 'Document successfully sent'.

COMMIT WORK.

ENDIF.

This should give you all you need to know to send an HTML file.

Thanks buddy