2010 Aug 06 10:38 AM
Hi Guys,
I am having some issue with sending html formatted mail in text body. I am using cl_bcs and cl_document_bcs.
When I create the document and give the document type as 'TXT', then the content is present in the mail body. But when I give the type as 'HTM', then the mail comes as an attachment. Can anybody please give me the reason for it?
Code used:-
document = cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = html
i_header = li_header
i_length = conlengths
i_subject = k_subject ).
send_request->set_document( document ).
send_request->set_send_immediately( 'X' ).
recipient = cl_cam_address_bcs=>create_internet_address( k_rec ).
add recipient with its respective attributes to send request
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient
i_express = 'X'.
CALL METHOD send_request->set_status_attributes
EXPORTING
i_requested_status = 'N'
i_status_mail = 'N'.
CALL METHOD send_request->set_send_immediately( 'X' ).
sent_to_all = send_request->send( i_with_error_screen = 'X' ).
2010 Aug 06 11:16 AM
Hello,
Although it doesn't use the class you are using, there is a blog which shows how to send e-mail formatted in HTML.
http://help-abap.blogspot.com/2008/09/sapconnect-email-with-formatting.html
Hi Guys,
I am having some issue with sending html formatted mail in text body. I am using cl_bcs and cl_document_bcs.
When I create the document and give the document type as 'TXT', then the content is present in the mail body. But when I give the type as 'HTM', then the mail comes as an attachment. Can anybody please give me the reason for it?
Code used:-
document = cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = html
i_header = li_header
i_length = conlengths
i_subject = k_subject ).
send_request->set_document( document ).
send_request->set_send_immediately( 'X' ).
recipient = cl_cam_address_bcs=>create_internet_address( k_rec ).
add recipient with its respective attributes to send request
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient
i_express = 'X'.
CALL METHOD send_request->set_status_attributes
EXPORTING
i_requested_status = 'N'
i_status_mail = 'N'.
CALL METHOD send_request->set_send_immediately( 'X' ).
sent_to_all = send_request->send( i_with_error_screen = 'X' ).
2010 Aug 06 11:16 AM
Hello,
Although it doesn't use the class you are using, there is a blog which shows how to send e-mail formatted in HTML.
http://help-abap.blogspot.com/2008/09/sapconnect-email-with-formatting.html
2010 Aug 06 11:25 AM
Thanks Kris,
But, it is still not working. I think there is some issue with the setting in SAP server. I have just found out that the same code is working well in the other server, that is, the content is in the mail body and not as an attachment. But, it is not working in the server I am using. When I send format content as 'htm' , then it sends it as an attachment
2010 Aug 06 4:34 PM
Your email code looks fine; hopefully your HTML code is fine as well. Check the SAPConnect settings on both servers for FORCE_FIRSTBODY_IS_TEXT. ( SCOT -> Settings -> General Parameters )
2010 Aug 09 5:34 AM
Hi Brad,
Thiis parameter is not present in any of the two servers I am testing. Do you think I should add this parameter?
2010 Aug 09 2:45 PM
Well, if neither server has the setting and one server works, then I doubt it's the issue. The FORCE_FIRSTBODY_IS_TEXT setting was primarily used for PDF content to be interpreted correctly in earlier versions with some mail clients, but I also saw one note that covered HTML emails being converted to attachments (1397458). The setting won't hurt; I have it set in our SAPConnect config and most of our emails are HTML-based.
If this doesn't work, use the internal trace function to determine how the email is being handled: SCOT -> Utilities -> Trace Settings. Also, if your html is complicated, start with some basic html and simple text as well to determine if there's an issue with that part of the code.
2010 Aug 07 7:23 AM
Hi Jas,
HTML internal table needs to be built and passed into the method cl_document_bcs=>create_document. Please make sure the HTML for the email content is collected in an internal table.
Thanks and Best Regards,
Dinesh.
cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = int_html
i_length = conlengths
i_subject = wl_subject ).
Internal Table
-
DATA: int_html TYPE TABLE OF w3html,
wf_html LIKE LINE OF int_html.
Built the HTML string and append to the internal table and once you have the complete HTML, create the document.
2010 Aug 07 7:23 AM
Hi Jas,
HTML internal table needs to be built and passed into the method cl_document_bcs=>create_document. Please make sure the HTML for the email content is collected in an internal table.
Thanks and Best Regards,
Dinesh.
cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = int_html
i_length = conlengths
i_subject = wl_subject ).
Internal Table
-
DATA: int_html TYPE TABLE OF w3html,
wf_html LIKE LINE OF int_html.
Built the HTML string and append to the internal table and once you have the complete HTML, create the document.