2008 Dec 24 11:00 AM
hi ,
how to write code to send mail in html fornat......please with some example reports
2008 Dec 25 10:46 AM
REPORT zsendemail .
PARAMETERS: psubject(40) type c default 'Hello',
p_email(40) type c default 'write mail id' .
data: it_packing_list like sopcklsti1 occurs 0 with header line,
it_contents like solisti1 occurs 0 with header line,
it_receivers like somlreci1 occurs 0 with header line,
it_attachment like solisti1 occurs 0 with header line,
gd_cnt type i,
gd_sent_all(1) type c,
gd_doc_data like sodocchgi1,
gd_error type sy-subrc.
data: it_message type standard table of SOLISTI1 initial size 0
with header line.
***********************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
Perform populate_message_table.
*Send email message, although is not sent from SAP until mail send
*program has been executed(rsconn01)
PERFORM send_email_message.
*Instructs mail send program for SAPCONNECT to send email(rsconn01)
perform initiate_mail_execute_program.
&----
*& Form POPULATE_MESSAGE_TABLE
&----
Adds text to email text table
----
form populate_message_table.
Append 'Email line 1' to it_message.
Append 'Email line 2' to it_message.
Append 'Email line 3' to it_message.
Append 'Email line 4' to it_message.
endform. " POPULATE_MESSAGE_TABLE
&----
*& Form SEND_EMAIL_MESSAGE
&----
Send email message
----
form send_email_message.
Fill the document data.
gd_doc_data-doc_size = 1.
Populate the subject/generic message attributes
gd_doc_data-obj_langu = sy-langu.
gd_doc_data-obj_name = 'SAPRPT'.
gd_doc_data-obj_descr = psubject.
gd_doc_data-sensitivty = 'F'.
Describe the body of the message
clear it_packing_list.
refresh it_packing_list.
it_packing_list-transf_bin = space.
it_packing_list-head_start = 1.
it_packing_list-head_num = 0.
it_packing_list-body_start = 1.
describe table it_message lines it_packing_list-body_num.
it_packing_list-doc_type = 'RAW'.
append it_packing_list.
Add the recipients email address
clear it_receivers.
refresh it_receivers.
it_receivers-receiver = p_email.
it_receivers-rec_type = 'U'.
it_receivers-com_type = 'INT'.
it_receivers-notif_del = 'X'.
it_receivers-notif_ndel = 'X'.
append it_receivers.
Call the FM to post the message to SAPMAIL
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = gd_doc_data
put_in_outbox = 'X'
importing
sent_to_all = gd_sent_all
tables
packing_list = it_packing_list
contents_txt = it_message
receivers = it_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.
Store function module return code
gd_error = sy-subrc.
Get it_receivers return code
loop at it_receivers.
endloop.
endform. " SEND_EMAIL_MESSAGE
&----
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
&----
Instructs mail send program for SAPCONNECT to send email.
----
form initiate_mail_execute_program.
wait up to 2 seconds.
if gd_error eq 0.
submit rsconn01 with mode = 'INT'
with output = 'X'
and return.
endif.
endform. "
hi ,
how to write code to send mail in html fornat......please with some example reports
2008 Dec 24 11:05 AM
2008 Dec 24 11:06 AM
Hi,
You can refer the below code.
*=====================================================================
* SEND AN EMAIL *
*=====================================================================
PARAMETERS: p_email LIKE pa0105-usrid_long
DEFAULT 'eswaratxxxl.com'.
*----------------------------------------------------------------------
*
* D A T A F O R S E N D I N G E M A I L
*----------------------------------------------------------------------
*
DATA: wa_objcont LIKE solisti1,
wa_reclist LIKE somlreci1,
wa_objpack LIKE sopcklsti1,
wa_objhead LIKE solisti1,
wa_content LIKE solisti1,
wa_doc LIKE sodocchgi1.
DATA: it_objcont TYPE STANDARD TABLE OF solisti1,
it_reclist TYPE STANDARD TABLE OF somlreci1,
it_objpack TYPE STANDARD TABLE OF sopcklsti1,
it_objhead TYPE STANDARD TABLE OF solisti1,
it_content TYPE STANDARD TABLE OF solisti1.
DATA: fv_lines TYPE i.
MOVE '<body>' TO wa_objcont.
APPEND wa_objcont TO it_objcont.
MOVE '<p>' TO wa_objcont.
APPEND wa_objcont TO it_objcont.
MOVE 'This is a test' TO wa_objcont.
APPEND wa_objcont TO it_objcont.
MOVE '</p>' TO wa_objcont.
APPEND wa_objcont TO it_objcont.
MOVE '</body>' TO wa_objcont.
APPEND wa_objcont TO it_objcont.
wa_reclist-receiver = p_email.
wa_reclist-rec_type = 'U'.
wa_reclist-copy = ' '.
wa_reclist-blind_copy = ' '.
wa_reclist-no_forward = ' '.
wa_reclist-no_print = ' '.
APPEND wa_reclist TO it_reclist.
* Creation of the document attachment
wa_objhead = 'TEST.HTM'.
APPEND wa_objhead TO it_objhead.
wa_content = 'Please see the report in the attachment'.
APPEND wa_content TO it_content.
DESCRIBE TABLE it_content LINES fv_lines.
READ TABLE it_content INTO wa_content INDEX fv_lines.
wa_doc-doc_size = ( fv_lines - 1 ) * 255 + STRLEN( wa_content ).
wa_doc-obj_langu = 'E'.
wa_doc-obj_name = 'NOTIFICATION'.
wa_doc-obj_descr = 'Event Notifier Progam Test'.
wa_doc-sensitivty = 'C'.
* Creation of the entry for the compressed document (MAIN)
CLEAR wa_objpack-transf_bin.
wa_objpack-head_start = 1.
wa_objpack-head_num = 0.
wa_objpack-body_start = 1.
wa_objpack-body_num = fv_lines.
wa_objpack-doc_type = 'RAW'.
APPEND wa_objpack TO it_objpack.
CLEAR wa_objpack.
* Creation of the entry for the compressed attachment
DESCRIBE TABLE it_objcont LINES fv_lines.
READ TABLE it_objcont INTO wa_objcont INDEX fv_lines.
wa_objpack-doc_size = ( fv_lines - 1 ) * 255 + STRLEN( wa_objcont )
.
wa_objpack-transf_bin = 'X'.
wa_objpack-head_start = 1.
wa_objpack-head_num = 0.
wa_objpack-body_start = 1.
wa_objpack-body_num = fv_lines.
wa_objpack-doc_type = 'HTM' .
wa_objpack-obj_name = 'Notification'.
wa_objpack-obj_descr = 'Event Notifier Progam'.
APPEND wa_objpack TO it_objpack.
*& Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc
put_in_outbox = 'X'
TABLES
packing_list = it_objpack
object_header = it_objhead
contents_bin = it_objcont
contents_txt = it_content
receivers = it_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
IF sy-subrc <> 0.
WRITE:/ 'DOCUMENT NOT SENT'.
ENDIF.Regards
Eswar
Edited by: Eswar Kanakanti on Dec 24, 2008 12:08 PM
2008 Dec 24 11:54 AM
whn i excuted data is not passing and also mail is not receiving can clarly send the cod plz
2008 Dec 24 11:24 AM
2008 Dec 25 6:55 AM
Import the list from memory and store it in table listobject
by using below FM
CALL FUNCTION 'LIST_FROM_MEMORY'
Write a list of SAPconnect conversion rules
Save the list and store table listobject
CALL FUNCTION 'SAVE_LIST'
It's always necessary to compress the list
SAPconnect will decompress it
CALL FUNCTION 'TABLE_COMPRESS'
Get list from spool
CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
EXPORTING
RQIDENT = SPOOL_NUMBER
TABLES
BUFFER = COMPRESSED_LIST
Use below FM's for sending via mail or fax
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
CALL FUNCTION 'SO_USER_ADDRESS_READ_API1'
2008 Dec 25 10:46 AM
REPORT zsendemail .
PARAMETERS: psubject(40) type c default 'Hello',
p_email(40) type c default 'write mail id' .
data: it_packing_list like sopcklsti1 occurs 0 with header line,
it_contents like solisti1 occurs 0 with header line,
it_receivers like somlreci1 occurs 0 with header line,
it_attachment like solisti1 occurs 0 with header line,
gd_cnt type i,
gd_sent_all(1) type c,
gd_doc_data like sodocchgi1,
gd_error type sy-subrc.
data: it_message type standard table of SOLISTI1 initial size 0
with header line.
***********************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
Perform populate_message_table.
*Send email message, although is not sent from SAP until mail send
*program has been executed(rsconn01)
PERFORM send_email_message.
*Instructs mail send program for SAPCONNECT to send email(rsconn01)
perform initiate_mail_execute_program.
&----
*& Form POPULATE_MESSAGE_TABLE
&----
Adds text to email text table
----
form populate_message_table.
Append 'Email line 1' to it_message.
Append 'Email line 2' to it_message.
Append 'Email line 3' to it_message.
Append 'Email line 4' to it_message.
endform. " POPULATE_MESSAGE_TABLE
&----
*& Form SEND_EMAIL_MESSAGE
&----
Send email message
----
form send_email_message.
Fill the document data.
gd_doc_data-doc_size = 1.
Populate the subject/generic message attributes
gd_doc_data-obj_langu = sy-langu.
gd_doc_data-obj_name = 'SAPRPT'.
gd_doc_data-obj_descr = psubject.
gd_doc_data-sensitivty = 'F'.
Describe the body of the message
clear it_packing_list.
refresh it_packing_list.
it_packing_list-transf_bin = space.
it_packing_list-head_start = 1.
it_packing_list-head_num = 0.
it_packing_list-body_start = 1.
describe table it_message lines it_packing_list-body_num.
it_packing_list-doc_type = 'RAW'.
append it_packing_list.
Add the recipients email address
clear it_receivers.
refresh it_receivers.
it_receivers-receiver = p_email.
it_receivers-rec_type = 'U'.
it_receivers-com_type = 'INT'.
it_receivers-notif_del = 'X'.
it_receivers-notif_ndel = 'X'.
append it_receivers.
Call the FM to post the message to SAPMAIL
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = gd_doc_data
put_in_outbox = 'X'
importing
sent_to_all = gd_sent_all
tables
packing_list = it_packing_list
contents_txt = it_message
receivers = it_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.
Store function module return code
gd_error = sy-subrc.
Get it_receivers return code
loop at it_receivers.
endloop.
endform. " SEND_EMAIL_MESSAGE
&----
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
&----
Instructs mail send program for SAPCONNECT to send email.
----
form initiate_mail_execute_program.
wait up to 2 seconds.
if gd_error eq 0.
submit rsconn01 with mode = 'INT'
with output = 'X'
and return.
endif.
endform. "
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |