ABAP技术:发送内容带有图片的电子邮件
Send an email with image in thebody along with the text.
发送内容带有图片的电子邮件
We come across a requirment to have an image inthe body of an email. For example, we may need to have an image to be embedded besidesignature, for examplecompany logo.
我们可能遇到要将图片放在邮件正文中的需求,例如:我们可能需要一个带图的签名,例如放着公司LOGO。
Lets see how to achieve it stepby step. 让我们来看看如何一步一步实现
Before embedding an image,Let's have a brief look how to send an email usingCL_BCS with an example code snippet keeping the main emphasis on the image part. These steps will be useful while embedding the image.
潜入图片之前,让我用示例代码片段简单介绍下如何使用CL_BCS发送一封带图片的电子邮件。嵌入图片时,这些步骤都会用到。
First step is to create persistent.第一步创建persistent
o Use the method CREATE_PERSISTENT of the class CL_BCS tosend request object of the standard class CL_BCS.
o Create BCS document
ob_bcs = cl_bcs=>create_persistent( ).
Second step is to create document.第二步创建document
Use the method CREATE_DOCUMENT of the classCL_BCS to create the message body.
ob_document =cl_document_bcs=>create_document(i_type = 'HTM'
i_subject = fp_subject
i_text =fp_it_text ).
Fill the fp_it_text with the html codingwhich you want to get displayed in the message body like below.
填写fp_it_text你想要得到像下面显示在邮件正文中的HTML代码。
Click on binary data for webRFC applicationsand execute. You get to see the below screen.
点击webRFC应用程序的二进制数据和执行。你能看到下面的屏幕。
Now execute without giving any values.
现在执行,不给予任何值。
Click onnew button and upload your image. Assign a package and transport also.
点击新建按钮,上传您的图片。
It will appear in the list as above.它会出现在上述列表
Sometimes, you may encounter an error"No MIME type assigned to object". If so, go to SMW0 transaction,find "settings" in the menu bar and under that find "maintainMIME types" option.
有时候,你可能会遇到一个错误,“没有MIME类型分配给对象”。如果是这样的话,去SMW0事务,发现在菜单栏中的“设置”下,找到“保持MIME类型”选项。
Check whether the extension with which youare uploading is there or not. Maintain there and you will be able to upload.
检查是否您要上载的扩展是有或没有。维护在那里再上传。
Now go to step 2 as mentioned in the sending a simplemail part, fill the fp_it_text table as below. Give the name with which thepicture is stored in SMW0 transaction.
现在进入第2步中提到的发送一个简单的邮件部分,填补了fp_it_text如下表。提供的名称与该图像被存储在SMW0事务。
ob_document->add_attachment( i_attachment_type = 'BMP' i_attachment_subject = 'NAME’ i_att_content_hex = it_pick_data ).Follow the rest of the steps for sending themail normally.
剩下的步骤请按照正常发送邮件。
Please letme know if you have need any clarifications
请让我知道,如果你需要任何说明

