2005 Sep 20 4:01 AM
hiii,
i have posted a problem in the following thread.
at some extent Surpreet is able to solve the problem, but now we r stuck to this that email is coming with attachment but not the exact that i am attching and trying to send the mail.
can any one check this code and rectify if any error is there.
REPORT YBALTEST.
DATA: gd_cnt TYPE i,
gd_sent_all(1) TYPE c,
gd_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc.
DATA: it_message LIKE solisti1 OCCURS 0 WITH HEADER LINE,
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.
* Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0,
row(255).
DATA: END OF it_pdf_output.
START-OF-SELECTION.
perform send_email_message .
*&---------------------------------------------------------------------*
*& Form SEND_EMAIL_MESSAGE
*&---------------------------------------------------------------------*
* Send email message
*----------------------------------------------------------------------*
FORM send_email_message.
DATA: tab_lines LIKE SY-TABIX.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:test.pdf'
filetype = 'BIN'
TABLES
data_tab = it_pdf_output .
* Populate the subject/generic message attributes
concatenate 'Attached is the '
' are waiting for.' into it_message.
append it_message.
DESCRIBE TABLE it_message LINES tab_lines.
READ TABLE it_message INDEX tab_lines.
gd_doc_data-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( it_message ).
gd_doc_data-obj_langu = sy-langu.
gd_doc_data-obj_name = 'SENDFILE'.
gd_doc_data-obj_descr = 'Attachement'.
gd_doc_data-sensitivty = 'O'.
describe table it_pdf_output lines tab_lines.
* Describe the body of the message
CLEAR it_packing_list-transf_bin.
it_packing_list-head_start = 1.
it_packing_list-head_num = 0.
it_packing_list-body_start = 1.
it_packing_list-doc_type = 'RAW'.
it_packing_list-body_num = tab_lines.
APPEND it_packing_list.
describe table it_pdf_output lines tab_lines.
CLEAR it_packing_list.
it_packing_list-transf_bin = 'X'.
it_packing_list-head_start = 1.
it_packing_list-head_num = 1.
it_packing_list-body_start = 1.
it_packing_list-doc_type = 'RAW'.
it_packing_list-body_num = tab_lines.
it_packing_list-doc_size = tab_lines * 255.
it_packing_list-OBJ_DESCR = ' object '.
it_packing_list-obj_name = 'MAIL'.
APPEND it_packing_list.
it_receivers-receiver = '[email protected]'.
it_receivers-rec_type = 'U'.
it_receivers-com_type = 'INT'.
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'
commit_work = 'X'
* IMPORTING
* sent_to_all = gd_sent_all
TABLES
packing_list = it_packing_list
contents_txt = it_message
contents_bin = it_pdf_output
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.
ENDFORM. " SEND_EMAIL_MESSAGEthanx
abhishek suppal
2005 Sep 20 5:07 AM
It will work even if you dont use OBJBIN . Just comment the following line in your original code -
it_packing_list-obj_name = 'MAIL'.
However it is a good practice to pass compatible / similar parameters to FM.
Cheers
hiii,
i have posted a problem in the following thread.
at some extent Surpreet is able to solve the problem, but now we r stuck to this that email is coming with attachment but not the exact that i am attching and trying to send the mail.
can any one check this code and rectify if any error is there.
REPORT YBALTEST.
DATA: gd_cnt TYPE i,
gd_sent_all(1) TYPE c,
gd_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc.
DATA: it_message LIKE solisti1 OCCURS 0 WITH HEADER LINE,
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.
* Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0,
row(255).
DATA: END OF it_pdf_output.
START-OF-SELECTION.
perform send_email_message .
*&---------------------------------------------------------------------*
*& Form SEND_EMAIL_MESSAGE
*&---------------------------------------------------------------------*
* Send email message
*----------------------------------------------------------------------*
FORM send_email_message.
DATA: tab_lines LIKE SY-TABIX.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:test.pdf'
filetype = 'BIN'
TABLES
data_tab = it_pdf_output .
* Populate the subject/generic message attributes
concatenate 'Attached is the '
' are waiting for.' into it_message.
append it_message.
DESCRIBE TABLE it_message LINES tab_lines.
READ TABLE it_message INDEX tab_lines.
gd_doc_data-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( it_message ).
gd_doc_data-obj_langu = sy-langu.
gd_doc_data-obj_name = 'SENDFILE'.
gd_doc_data-obj_descr = 'Attachement'.
gd_doc_data-sensitivty = 'O'.
describe table it_pdf_output lines tab_lines.
* Describe the body of the message
CLEAR it_packing_list-transf_bin.
it_packing_list-head_start = 1.
it_packing_list-head_num = 0.
it_packing_list-body_start = 1.
it_packing_list-doc_type = 'RAW'.
it_packing_list-body_num = tab_lines.
APPEND it_packing_list.
describe table it_pdf_output lines tab_lines.
CLEAR it_packing_list.
it_packing_list-transf_bin = 'X'.
it_packing_list-head_start = 1.
it_packing_list-head_num = 1.
it_packing_list-body_start = 1.
it_packing_list-doc_type = 'RAW'.
it_packing_list-body_num = tab_lines.
it_packing_list-doc_size = tab_lines * 255.
it_packing_list-OBJ_DESCR = ' object '.
it_packing_list-obj_name = 'MAIL'.
APPEND it_packing_list.
it_receivers-receiver = '[email protected]'.
it_receivers-rec_type = 'U'.
it_receivers-com_type = 'INT'.
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'
commit_work = 'X'
* IMPORTING
* sent_to_all = gd_sent_all
TABLES
packing_list = it_packing_list
contents_txt = it_message
contents_bin = it_pdf_output
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.
ENDFORM. " SEND_EMAIL_MESSAGEthanx
abhishek suppal
2005 Sep 20 4:10 AM
hi
one error i left
describe table it_pdf_output lines tab_lines.
Describe the body of the message
CLEAR it_packing_list-transf_bin.
it_packing_list-head_start = 1.
it_packing_list-head_num = 0.
it_packing_list-body_start = 1.
it_packing_list-doc_type = 'RAW'.
it_packing_list-body_num = tab_lines.
APPEND it_packing_list.
describe table it_pdf_output lines tab_lines
delete first describe
although it will not remove the error we are facing
regards
2005 Sep 20 4:14 AM
What are you getting as the attachment? Is it just unreadable or some other pdf document?
2005 Sep 20 4:17 AM
just unreadable
like this
¥äãã®âî¢íà¨ã±ã¸ã æ¼ æ©¢ã° â¼¼æ¥æ®ç¡ç©©æ¥ã ä°¯ã ã²ã²â¼¶âã±ã¸ä¯ã 㤷ã´ä¸¯ã â¼¹â㤲ã¹ã´ä ¯å¬ ã ãµâ·ã¹å´¶ã¸¾ææ®æ¯àµªâ â â â â à¨ç¸æ¥à¨ã±ã¸ã à´±ãã°ã°ã°ã°â¶ã°ã°â°àµ®ãã°ã°ã°ã¤¶â¹ã°ã°â°àµ®ãã°ã°ã°ã¸â·ã°ã°â°àµ®ãã°ã°ã°ã±â³ã°ã°â°àµ®ãã°ã°ã°ã³â²ã°ã°â°àµ®ãã°ã°ã°ã µâ°ã°ã°â°àµ®ãã°ã°ã°ã¶â¸ã°ã°â°àµ®ãã°ã°ã°ã¸â²ã°ã°â°àµ®ãã°ã°ã°ã ¸â°ã°ã°â°àµ®ãã°ã°ã°ãµâ±ã°ã°â°àµ®ãã°ã°ã´ãµâ¹ã°ã°â°àµ®ãã°ã°ã´ã¶â²ã°ã°â°àµ®ãã°ã°ã´ã·â³ã°ã°â°àµ®ãã°ã°ã´ã¸â¶ã°ã°â°àµ®ãã°ã°ã´ã¹â°ã°ã°â°àµ®ãã°ã°ã´ã °â´ã°ã°â°àµ®ãã°ã°ã´ã±â¸ã°ã°â°àµ®ãã°ã°ã´ã³âµã°ã°â°àµ®ãã°ã°ã´ãµâ¸ã°ã°â°àµ®
ãã°ã°ã´ãµâ²ã°ã°â°àµ®ãã°ã°ã´ã·â¸ã°ã°â°àµ®ãã°ã°ã´ã¹âµã°ã°â°àµ®ãã°ã°ã´ã±â¶ã°ã°â°àµ®ãã°ã°ã´ã±â°ã°ã°â°àµ®ãã°ã°ã´ã³â¶ã°ã°â°àµ®ãã°ã°ã´ã´â¹ã°ã°â°àµ®ãã°ã°ã´ã¤´â²ã°ã°â°àµ®ãã°ã°ã´ã¤µâ´ã°ã°â°àµ®ãã°ã°ã´ã¶â¶ã°ã°â°àµ®ãã°ã°ã´ã·â´ã°ã°â°àµ®ãã°ã°ã´ã¸â¸ã°ã°â°àµ®ãã°ã°ã´ã°â´ã°ã°â°àµ®ãã°ã°ã´ã²â°ã°ã°â°àµ®ãã°ã°ã´ã ³â¶ã°ã°â°àµ®ãã°ã°ã´ã´â°ã°ã°â°àµ®ãã°ã°ã´ãµâ·ã°ã°â°àµ®ãã°ã°ã´ã¶â±ã°ã°â°àµ®ãã°ã°ã´ã ¶âµã°ã°â°àµ®ãã°ã°ã´ã·â¹ã°ã°â°àµ®ãã°ã°ã´ã¹â·ã°ã°â°àµ®ãã°ã°ã´ã¹â±ã°ã°â°àµ®ãã°ã°ã´ã²â¸ã°ã°â°àµ®ãã°ã°ã´ã²â²ã°ã°â°àµ®ãã°ã°ã´ãµâ·ã°ã°â°àµ®ãã°ã°ã´ãµ
â±ã°ã°â°àµ®ãã°ã°ã´ã·â¶ã°ã°â°àµ®ãã°ã°ã´ã¤·â°ã°ã°â°àµ®ãã°ã°ã´ã¹â²ã°ã°â°àµ®ãã°ã°ã´ã°â¶ã°ã°â°àµ®ãã°ã°ã´ã°â°ã°ã°â°àµ®ãã°ã°ã´ã±â´ã°ã°â°àµ®ãã°ã°ã´ã ²â¸ã°ã°â°àµ®ãã°ã°ã´ã³â²ã°ã°â°àµ®ãã°ã°ã´ã´â¸ã°ã°â°àµ®ãã°ã°ã´ãµâ²ã°ã°â°àµ®ãã°ã°ã´ã·â·ã°ã°â°àµ®ãã°ã°ã´ã¤·â±ã°ã°â°àµ®ãã°ã°ã´ã¸âµã°ã°â°àµ®ãã°ã°ã´ã¤¸â¹ã°ã°â°àµ®ãã°ã°ã°ã¤´â³ã°ã°â°àµ®ãã°ã°ã°ãµâ·ã°ã°â°àµ®çæ ²æ±©ç¥à¨ã°¼å¯ç©©â¥ã±ã´å¯æ²â¶ã¤²ã¹ã²å ¯æå¦æµ´ã 㤴⼳æ½ç¯ã ã ²âµâ°â½æ¹ ç£ç¹â´ã±ã¸ã å 䤯æ®â¯ã²â³â°â½äã±ãã·ãµã±ã²ãäääãµä³ä¸ã¹ã°ã±ä±ã°¾ã°ã¤°ä±ã ãä¹ã³ä´äãä´äµã·äãä崾㸾à¨ç³ç¡ç¡´æ²àµ¦ã
à¨â¥ä½ àµââ â â â â â â â â â â â à´ ãã³â³â°æ¯ã±ªâ¼¼ææ®æ¡´ã ã²ä¯ã ã³â¼·æ¥ç¬ç¥ä¯æ ¬æ´ææ½£æ¤ä¤¯ã ã´â¼²âã±ã±ä¼¯ã 㤲⼵âã¹ã¸¶ç¾ç´æ ¥àµ#íé·¾å§îåï¼á½ï¡ëç¿ï¼##á¼½ìâ·êââ¦â®æºà®í#ë¼ë´ ä·ä¦îë½ì°Øæ©ë¶£èµ¤è¾éà·åá®à§ªê«é¢ë媸쯨ä¶â£î¡äí î®äé¿¦ì½æá鮽îäæ¾ïäî ã¥ªæ±£ï ¯ç±½é¡ç¨âªä»êçï·ä¤à³®äé§ãè©ä 桸î¦â³îºç©·ë¿ä¹êêº×¥æ£ê½îº#çµ¥ìëåí£ê¸¤îªµã¬ä®§î®ºäã´î´ç®¨äé²ãê¬îã®å±¤#å顿坶í£ä࣪å£äâ¬ç®²é¼¨íä½é´ï·ïé¶ì¥çë°ë°´â๸鱤ä鮿®¢é´ãë±ä»ï±ªÚì·çë¢æ¿ á¼å·»ë¸âë¯áµ¢æî⢮ï¥ì£¦îë¡¹ê¼æ¾ 颹åäªè¨¹èê·ä½ìÄâ¤é»î²±âæ£ë²¨èî»å¾#è¾ï®
ê»í½î¼ã¥â½äºã¬¸ïç²ï¥ã¤êè
regards
Message was edited by: Surpreet Singh Bal
2005 Sep 20 4:21 AM
yes something like this is getting in the attachment file.
also surpreet i have done something
CLEAR it_packing_list.
it_packing_list-transf_bin = 'X'.
it_packing_list-head_start = 1.
it_packing_list-head_num = 1.
it_packing_list-body_start = 1.
it_packing_list-doc_type = 'RAW'.
it_packing_list-body_num = tab_lines.
it_packing_list-doc_size = tab_lines * 255.
* it_packing_list-obj_descr = ' object '.
it_packing_list-obj_descr = 'test.pdf'.
it_packing_list-obj_name = 'MAIL'.
APPEND it_packing_list.by doing so we can get the exact file name, .
abhishek suppal
2005 Sep 20 4:24 AM
Does your internet email node allow PDF type documents to be sent? Check in transaction SCOT for the node, if *.pdf is there.
Srinivas
2005 Sep 20 4:29 AM
yes srinivas its there in scot
and also surpreet i have just check it for txt file it is going well, but for pdf file its something like the above format, may be i thing i have just debug the function GUI_UPLOAD the internal table got all the data in binary format may be we have to see there....
abhishek suppal
2005 Sep 20 4:54 AM
Hi Abhisek
I am pasting the exact code which will work.
REPORT YBALTEST.
DATA: gd_cnt TYPE i,
gd_sent_all(1) TYPE c,
gd_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc.
DATA OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
DATA: it_message LIKE solisti1 OCCURS 0 WITH HEADER LINE,
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.
Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0,
row(255).
DATA: END OF it_pdf_output.
START-OF-SELECTION.
perform send_email_message .
&----
*& Form SEND_EMAIL_MESSAGE
&----
Send email message
----
FORM send_email_message.
DATA: tab_lines LIKE SY-TABIX.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\test.pdf'
filetype = 'BIN'
TABLES
data_tab = it_pdf_output .
Populate the subject/generic message attributes
concatenate 'Attached is the '
' are waiting for.' into it_message.
append it_message.
DESCRIBE TABLE it_message LINES tab_lines.
READ TABLE it_message INDEX tab_lines.
gd_doc_data-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( it_message ).
gd_doc_data-obj_langu = sy-langu.
gd_doc_data-obj_name = 'SENDFILE'.
gd_doc_data-obj_descr = 'Attachement'.
gd_doc_data-sensitivty = 'O'.
describe table it_pdf_output lines tab_lines.
Describe the body of the message
CLEAR it_packing_list-transf_bin.
it_packing_list-head_start = 1.
it_packing_list-head_num = 0.
it_packing_list-body_start = 1.
it_packing_list-doc_type = 'RAW'.
it_packing_list-body_num = tab_lines.
APPEND it_packing_list.
loop at it_pdf_output.
move it_pdf_output-row to objbin-line.
append objbin.
endloop.
describe table objbin lines tab_lines.
CLEAR it_packing_list.
it_packing_list-transf_bin = 'X'.
it_packing_list-head_start = 1.
it_packing_list-head_num = 1.
it_packing_list-body_start = 1.
it_packing_list-doc_type = 'PDF'.
it_packing_list-body_num = tab_lines.
it_packing_list-doc_size = tab_lines * 255.
it_packing_list-OBJ_DESCR = ' object '.
*it_packing_list-obj_name = 'MAIL'.
APPEND it_packing_list.
it_receivers-receiver = '[email protected]'.
it_receivers-rec_type = 'U'.
it_receivers-com_type = 'INT'.
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'
commit_work = 'X'
IMPORTING
sent_to_all = gd_sent_all
TABLES
packing_list = it_packing_list
contents_txt = it_message
contents_bin = objbin
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.
ENDFORM. " SEND_EMAIL_MESSAGE
Cheers
2005 Sep 20 4:58 AM
yes sanjay
you are right i missed to put data in objbin-line
regards
2005 Sep 20 5:07 AM
It will work even if you dont use OBJBIN . Just comment the following line in your original code -
it_packing_list-obj_name = 'MAIL'.
However it is a good practice to pass compatible / similar parameters to FM.
Cheers
2005 Sep 20 6:38 AM
yes it works,
important point
doc_type = 'PDF'.
regards
thanks sanjay, abhi please close your both threads
2005 Sep 20 7:02 AM
yes surpreet
doc_type = 'PDF'
is the main thing
and also i have checked it for excel file putting
doc_type = 'XLS'
and for Word file
doc_type = 'DOC'
it works fine....
thanx sanjay and surpreet for ur efforts
ya sure i am going to close both threads and reward the points..
abhishek suppal
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |