on 01-23-2006 5:36 PM
Team,
I have defined a job via SM36:
program name : RM06BA00
send output to:Distribution List.
The email received in the MsOutlook inBox shows the message as an attachment. I want the contents of the message shown in the body of the email. Any ideas? (Emails are received in .HTM extension)
Thanks
PS. Gmail and Hotmail emails shows the message as attachment. Yahoo shows the contents of the message in the body of the email.
One idea is to have a wrapper program around your RM06BA00. Check this sample program, here we are submitting the program, getting the list from memory, formatting into HTML then putting it in the body of the email and sending. Works great in my system.
report zrich_0003 .
data: maildata like sodocchgi1.
data: mailtxt like solisti1 occurs 10 with header line.
data: mailrec like somlrec90 occurs 0 with header line.
data: list type table of abaplist with header line.
data: ascilines(1024) type c occurs 0 with header line.
data: htmllines type table of w3html with header line.
parameters: p_check.
start-of-selection.
* Here you would submit the program with parameters
* and export it to memory.
submit zrich_0004 exporting list to memory and return.
* Get the list from memory
call function 'LIST_FROM_MEMORY'
tables
listobject = list
exceptions
not_found = 1
others = 2.
* Format to HTML
call function 'WWW_HTML_FROM_LISTOBJECT'
tables
html = htmllines
listobject = list.
clear: maildata, mailtxt, mailrec.
refresh: mailtxt, mailrec.
maildata-obj_name = 'TEST'.
maildata-obj_descr = 'Test Subject'.
* Move the HTML lines into the body
* of the email
loop at htmllines.
mailtxt = htmllines.
append mailtxt.
endloop.
mailrec-receiver = you@yourcompany.com'.
mailrec-rec_type = 'U'.
append mailrec.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_data = maildata
document_type = 'HTM'
put_in_outbox = '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.
* Here you are forcing the system to send
* the email right away.
commit work.
wait up to 2 seconds.
submit rsconn01 with mode = 'INT'
with output = 'X'
and return.
Regards,
Rich Heilman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Rich,
Thanks for your reply -
My email is blank - there is nothing in the body.
When I debugg, the "list" is blank.
*********
call function 'LIST_FROM_MEMORY' tables listobject = list exceptions not_found = 1 others = 2.* Format to HTML call function 'WWW_HTML_FROM_LISTOBJECT' tables html = htmllines listobject = list.
*********
Do you know what could be the reason?
<b>The code is attaced below</b>
&----
*& Report ZSDN_SENDTXTVIAEMAIL *
*& *
&----
*& *
*& *
&----
REPORT ZSDN_SENDTXTVIAEMAIL .
*report zrich_0003 .
data: maildata like sodocchgi1.
data: mailtxt like solisti1 occurs 10 with header line.
data: mailrec like somlrec90 occurs 0 with header line.
data: list type table of abaplist with header line.
data: ascilines(1024) type c occurs 0 with header line.
data: htmllines type table of w3html with header line.
parameters: p_check.
start-of-selection.
Here you would submit the program with parameters
and export it to memory.
submit zrich_0004 exporting list to memory and return.
submit RM06BA00
USING SELECTION-SET 'OPEN REQ' "a variant
USING SELECTION-SETS OF PROGRAM 'RM06BA00'
*
exporting list to memory and return. "Disp REqs pgm
Get the list from memory
call function 'LIST_FROM_MEMORY'
tables
listobject = list
exceptions
not_found = 1
others = 2.
Format to HTML
call function 'WWW_HTML_FROM_LISTOBJECT'
tables
html = htmllines
listobject = list.
clear: maildata, mailtxt, mailrec.
refresh: mailtxt, mailrec.
maildata-obj_name = 'TEST'.
maildata-obj_descr = 'Test Subject'.
Move the HTML lines into the body
of the email
loop at htmllines.
mailtxt = htmllines.
append mailtxt.
endloop.
mailrec-receiver = 'naved.rehman@gmail.com'.
mailrec-rec_type = 'U'.
append mailrec.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_data = maildata
document_type = 'HTM'
put_in_outbox = '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.
Here you are forcing the system to send
the email right away.
commit work.
wait up to 2 seconds.
submit rsconn01 with mode = 'INT'
with output = 'X'
and return.
Ok, here is a solution. It works really good with ALVs as output in the sumbitted program. In this case the RM06BA00 is a little strange. Even if you submit it to SAP-SPOOL the list still is display. So in order for this program to work you must run it in the background.
report zrich_0002.
data: maildata like sodocchgi1.
data: mailtxt like solisti1 occurs 10 with header line.
data: mailrec like somlrec90 occurs 0 with header line.
data: list type table of abaplist with header line.
data: ascilines(1024) type c occurs 0 with header line.
data: htmllines type table of w3html with header line.
data: spool_number type tsp01-rqident.
data: spool_key type tsp01-rqtitle.
parameters: p_check.
start-of-selection.
concatenate 'rm06ba00' sy-uname sy-datum sy-uzeit into spool_key.
* Here you would submit the program with parameters
* and export it to memory.
submit rm06ba00
* using selection-set 'OPEN REQ' "a variant
* using selection-sets of program 'RM06BA00'
with ba_ekgrp-low = 'B10'
with BA_matkl-LOW = '236040'
with S_WERKS-LOW = '0007'
with S_FRGDT-LOW = '20060103'
to sap-spool
destination space
immediately space
cover text spool_key
keep in spool 'X'
new list identification 'X'
without spool dynpro
and return.
* Get the spool number from the table which was
* just created.
select single rqident from tsp01 into spool_number
where rqtitle = spool_key.
* This program will read the spool and put into memory
submit rspolst2 exporting list to memory and return
with rqident = spool_number
with first = '1'
with last = '99999'.
* Retrieve it from memory
call function 'LIST_FROM_MEMORY'
tables
listobject = list
exceptions
not_found = 1
others = 2.
* Format to HTML
call function 'WWW_HTML_FROM_LISTOBJECT'
tables
html = htmllines
listobject = list.
clear: maildata, mailtxt, mailrec.
refresh: mailtxt, mailrec.
maildata-obj_name = 'TEST'.
maildata-obj_descr = 'Test Subject'.
* Move the HTML lines into the body
* of the email
loop at htmllines.
mailtxt = htmllines.
append mailtxt.
endloop.
mailrec-receiver = 'rich.heilman@yorktwn.com'.
mailrec-rec_type = 'U'.
append mailrec.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_data = maildata
document_type = 'HTM'
put_in_outbox = '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.
* Also add your SUMBIT here for forcing the emails
* to be send.
I am sending you a copy of the output to you mail id.
Regards,
RIch Heilman
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.