‎2008 Feb 07 12:29 PM
Hi!!
I would like to send an email using SO_DOCUMENT_SEND_API1 fm.
I can write the message text into the TABLES contents_txt.
Are there any formatting options, while creating this email text?
I mean choosing fonts, using tabulators, making the fonts bold or italic, choose size, etc...
Thank you in advance
Tamá
‎2008 Feb 07 1:05 PM
‎2008 Feb 07 1:05 PM
‎2008 Feb 07 1:06 PM
Hi
Try below code it worked for me..It sends mail to external mail IDs as well..with Bold, italics edit options...
Hope it work for you.!!
&----
*& Report ZTUSM_SEND_MAIL *
*& *
&----
*& *
*& *
&----
REPORT ZTUSM_SEND_MAIL.
DATA: att_size TYPE i, " att Size
att_itab_size TYPE i, " Attachment size
mailtxt_size TYPE i. " Text in mail size
DATA:
it_mailpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE, " Dist details
it_mailhead LIKE solisti1 OCCURS 1 WITH HEADER LINE," Header data
it_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE, " Rec List
it_mailtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE, " Mail Text
it_att_data LIKE solisti1 OCCURS 0 WITH HEADER LINE, " Attachment data
it_doc_att LIKE sodocchgi1. " Attri of new doc
Text in the mail.
it_mailtxt-line =
'<BODY BGCOLOR="#FFFFCC">' &
' This is a test mail, Line Number--1'
.
APPEND it_mailtxt.
it_mailtxt-line = ' This is a test mail, Line Number--2' &
' This is a test mail, Line Number--2'.
APPEND it_mailtxt.
it_mailtxt-line = 'This is a test mail, Line Number--3' &
' This is a test mail, Line Number--3' &
' This is a test mail, Line Number--3'.
APPEND it_mailtxt.
DESCRIBE TABLE it_mailtxt LINES mailtxt_size.
Create the att File
concatenate 'Attachment Line Number 1' space into
it_att_data-line.
APPEND it_att_data.
concatenate 'Attachment Line Number 2' space into
it_att_data-line.
APPEND it_att_data.
concatenate 'Attachment Line Number 3' space into
it_att_data-line.
APPEND it_att_data.
DESCRIBE TABLE it_att_data LINES att_itab_size.
Attributes of new doc
CONCATENATE 'Attach' space 'mail'
INTO it_doc_att-obj_descr SEPARATED BY space.
it_doc_att-sensitivty = 'F'.
it_doc_att-doc_size = mailtxt_size * 255.
Create Pack to text in mail body.
it_mailpack-transf_bin = space.
it_mailpack-head_start = 1.
it_mailpack-head_num = 0.
it_mailpack-body_start = 1.
it_mailpack-body_num = mailtxt_size.
it_mailpack-doc_type = 'HTM'.
APPEND it_mailpack.
Create Pack for Attach.
it_mailpack-transf_bin = 'X'.
it_mailpack-head_start = 1.
it_mailpack-head_num = 1.
it_mailpack-body_start = 1.
it_mailpack-body_num = att_itab_size.
it_mailpack-doc_type = 'HTM'.
CONCATENATE 'My' space 'Attachment' INTO it_mailpack-obj_descr.
it_mailpack-doc_size = att_itab_size * 255.
APPEND it_mailpack.
it_reclist-receiver = 'tushar.mundlik@gmail.com'.
it_reclist-express = 'X'.
it_reclist-rec_type = 'U'.
*it_reclist-notif_del = 'X'. " request delivery notification
APPEND it_reclist.
Call FM to send email
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = it_doc_att
put_in_outbox = 'X'
TABLES
packing_list = it_mailpack
object_header = it_mailhead
contents_txt = it_mailtxt
contents_bin = it_att_data
receivers = it_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.
IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Mark if helpful
Regards
‎2008 Feb 08 1:12 PM
I have found the solution, have to create your letter in HTM to be able formatting.
Here are the key moments:
CONCATENATE '<b>' text-m10 '</b>:' anlz-kfzkz "text-m10 will be bold due to HTML formatting
INTO ls_text.
APPEND ls_text TO lt_text.
DESCRIBE TABLE lt_text LINES l_tab_lines.
* Document properties
CLEAR ls_packlist-transf_bin.
ls_packlist-head_start = 1.
ls_packlist-head_num = 0.
ls_packlist-body_start = 1.
ls_packlist-body_num = l_tab_lines.
ls_packlist-doc_type = 'HTM'.
APPEND ls_packlist TO lt_packlist.
* Send mail
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = ls_docudata
sender_address = l_sender
sender_address_type = 'B'
TABLES
packing_list = lt_packlist
contents_txt = lt_text
receivers = lt_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.
Dam, I'm good, where're my 10 points?