01-11-2015 3:43 PM
Hi, ABAP Community.
In our project there is a need to send a document to end-user e-mail account, in this specific case it is Microsoft Outlook. The sending is working, but I have a problem with the way it arrives the user mailbox. The HTM-file arrives as an attachment while I would like to see it in inline mode — straight in the message body.
Below, I post some code fragment to let you understand what exactly I'm doing. Suppose, my function has already the document in binary format (SOLIX_TAB), now in order to send the document the class CL_BCS is used and I have to follow the next steps:
document = cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = im_text
i_length = txt_len
i_subject = im_subject ).
CALL METHOD document->add_attachment
EXPORTING
i_attachment_type = 'DOC'
i_attachment_subject = im_document_name
i_att_content_hex = im_doc_attachment.
DATA: send_request TYPE REF TO cl_bcs.
CALL METHOD send_request->set_document( document ).
CALL METHOD send_request->set_send_immediately( 'X' ).
DATA: recipient TYPE REF TO if_recipient_bcs.
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient
i_express = 'X'.
CALL METHOD send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = sent_to_all ).
IF sent_to_all = 'X'.
WRITE text-003.
ENDIF.
COMMIT WORK.
As the result of this code execution, I got the blank email with two attachments: one with the HTM extension and one with the DOC. I would like that the content of the HTM-document (container with im_text, im_subject) will be displayed in the message body and the only DOC-file will be sent as an attachment. How can I get the desired result?
Thanks.
01-11-2015 5:09 PM
01-11-2015 5:09 PM
01-11-2015 6:33 PM
Hi Eitan,
The parameter i_text will receive some plain text, string which will be passed to the function method.
Thanks for the link, I'll check it.
01-12-2015 4:45 PM
Hi Eitan,
I tried to follow the example you provided. I definded the object of CL_HTM class which was also implemented according to your example, filled the the fragment property with:
ob_htm->append( fragment = '<p>' ).
ob_htm->append( fragment = 'Text' ).
ob_htm->append( fragment = '</p>' ).
Then, I converted ob_htm->htm_string to it_solix and created the document with parameter i_hex = it_solix. Finally, I send the document to email, but the problem still persists, the document has been sent as attachment instead of inline mode — in the body of the email and not as attachment. Could you, please, point me what I'm doing wrong?
P.S. Probably, there is a problem with MIME-definition. Should I define some specific MIME-value before the document will be sent?
01-12-2015 6:14 PM
Hi,
May I suggest that you copy the program to your system and run the program and see if you get what you need.
If the result is ok you can dissect the program......
There are:
PERFORM mail_1_prep_1 - Create the message body .
PERFORM mail_1_prep_2 - Create attachment .
cl_htm is just a fancy "edit and concatenate service" .
I look at the Internet to find out what is "email inline mode" and it seems that it has to do with pictures in the body of the mail .
When you say "inline mode" what do you mean ?
regards.
01-12-2015 6:56 PM
Under «inline mode» I mean the mode, where the content (text, picture etc.) is placed in the email body and not attached to the email as a separate file.
I'll check mail_1_prep_1 more deeply tomorrow.
Thanks.
01-12-2015 7:01 PM
01-14-2015 1:14 PM
Hi Eitan,
I completely copied the first code example (both mail_1_prep_1 and mail_1_prep_2) and tried to execute it. The program works, but the message content is still presented as attachments with the blank message body. I suppose, it's a matter of configuration of SAP/Exchange/Outlook and not the code-related issue. Can you recommend what and where should I check in order to achieve the desired result — the text of the message will be placed inside of the message body and not as an attachment with the empty message body.
Thanks.