We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Examples adding MapiAttachments

Are there any examples available of adding attachments and inline images via MapiAttachments to a MapiMessage? On the wiki I am only able to find examples of adding (inline) attachments to a MailMessage but I do not want to use MailMessage.

Thanks in advance!

Kind regards,
Yannick

Hi Yannick,


Thank you for writing to Aspose support team.

The MapiMessage class considers all the attachments and linked resources (that includes as inline images as well) as regular attachments for retrieval purpose. At present, I could not find any such method that could add an image as inline attachment. However, you can add regular attachments as follow:

Sample Code:


import java.nio.file.Files;

import java.nio.file.Paths;

import java.nio.file.Path;


Path path = Paths.get(“DContactP.jpg”);


MapiMessage msg = new MapiMessage("from@domain.com","to@domain.com",“Subject”, “body”);


msg.getAttachments().add(“Photo.jpg”, Files.readAllBytes(path));
Hi Kashif,


I managed to figure out how to add inline images. Similar to a regular attachments you add the inline image as attachment but afterwards you need to add a new MapiProperty to the attachment, setting the value of the 'PR_ATTACH_CONTENT_ID_W'-property to the 'cid' of the inline image that you placed in the HTML body of the e-mail.

Hi Yannick,


Thank you for sharing the feedback. We’ll look into it to make it part of our documentation guide and also give it a thought to provide any such method which is more user friendly. Please feel free to write to us in case you have any inquiry related to Aspose.Email.