on 2017 May 04 11:34 AM
Hi,
I am using SMTP relay server to send mails via XSJS project. I am able to send mails with HTML content and normal text type. However now i also want to embed images in the mails. I am using typical HTML format <img width=500 height=100 src=cid:Capture>", however it is not working.When the mail is received there is error shown in space of image : The linked image cannot be displayed.
Any pointers on how to send mails using xsjs using HTML content with embedded images.
Instead of an attachment you should create an mail part of type $.net.Mail.Part.TYPE_INLINE in which you can define the Content ID you refer in the HTML part.
You can check the example in the documentation: https://help.sap.com/http.svc/rc/3de842783af24336b6305a3c0223a369/2.0.01/en-US/$.net.Mail.Part.html
Please enclose the value of the image src attribute also in double quotes to avoid any issues (e.g. src="cid:CAPUTURE"). Of course you need to adjust the value to contain the defined content id in the inline part.
Regards,
Florian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks . i will follow the same. But what should i pass in the data1 value for the property "data" :
var firstPart =new $.net.Mail.Part();
firstPart.type = $.net.Mail.Part.TYPE_INLINE;
firstPart.data = data1;// data1 contains the binary data of the image firstPart.contentType ="image/jpg"; firstPart.contentId ="IMAGE1_ID"; firstPart.fileName ="fileName1.jpg"; firstPart.fileNameEncoding ="UTF-8";
Regards,
Namrata
The value that i am passing in property data is like
data:firstPart.data = "1000000000000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111"+ "1000000000000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111"+ "1000010010000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111"+ "1000011111000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111"+ "1000000111000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111"+ "1000010111000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111"+ "1000110111000011111111111111111111111111111111010111110111010100001010010111111111111111111111111111"+ "1000111111000011111111111111111111111111111111101101001111010001101001011111111111111111111111111111"+ "1001111111000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111"+ "1111111111000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111"+ "1111111111110011111111111111111111111111111111111111111111111111111111111111111111111111111111111111"+ "1111111111111011111111111111111111111111111111111111111111111111111111111111111111111111111111111111"+ "1111111111111011111111111111111111111111111111111111111111111111111111111111111111111111111111111111"+ "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111";
I have got this binary data of the image from a 3rd party tool to convert image to binary format. Is this fine or should i be doing it another way.Thanks in advance.
the image i want to send as mail hear is company logo and i have the compage logo image saved in png format on local file system. and i have pasted this image in the xs project created. Can you please advice.
Later i used this site http://www.dcode.fr/binary-image to conver the local image into binary format ? is this way correct. i couldnt find any documentation on how to get binary data of the image. Any advice is appreciated.
How do you read the image from the repo. I would assume that you get it already in the right format if you would use e.g. the file rest api or the objectslib xsjslib implementation (e.g. method getTarget of "sap.hana.xs.dt.base.server.objectsLib.xsjslib").
Hi Florian,
Yes i am using "sap.hana.xs.dt.base.server", "utilsLib") library to fetch the image using below code :
var workspace = "_SYS_BIC\.\...\app\gsap\ZPACKAGE\Namrata\Mailfunctionality\";
//var activationMode = 0;
; var version = -1;
var active = null;
var conn = $.db.getConnection(8);
var session = utilsLib.getInactiveSession(conn,workspace);
//var zip = new $.util.Zip();
var objects = XSDS.$defineEntity("Packages", '"_SYS_REPO"."ACTIVE_OBJECT"');
var jsonOut = {};
jsonOut.Objects = objects.$query().$project({OBJECT_NAME : true}) .$where(objects.PACKAGE_ID.$like(app.gsap.ZPACKAGE.Namrata.Mailfunctionality') .$and(objects.OBJECT_NAME.$like('%'))).$order({by : objects.OBJECT_NAME}).$distinct().$execute();
var object = jsonOut.Objects[0].OBJECT_NAME;
var path = "app/gsap/ZPACKAGE/Namrata/Mailfunctionality" + object + ".jpg";
if (objectsLib.getTarget(path, version, session, active)) {
return objectsLib.getTarget(path, version, session, active).bdata;
}
However i am getting error here at utilsLib.getInactiveSession(conn,workspace); as it says workspace column name is incorrect. I am suspecting it is due to the workspace variable i have passed. Do you know the correct format in which workspace should be passed.
Regards,
Namrata
User | Count |
---|---|
63 | |
10 | |
7 | |
7 | |
6 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.