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

Free Support Forum - aspose.com

Adding Attachments to a Message using Aspose.Network for Java

It appears that we can now add attachments to a MapiMessage using Aspose.Network for Java. I am having trouble finding documentation on how to add multiple inline attachments with
Aspose.Network for Java. Can you please point me in the right
direction?

Hi Brian,

I would like to share that Aspose.Network for Java has been discontinued for quite a long time now. You can use Aspose.Email for Java instead of this. Please have a look at the following code sample for your kind reference and let us know if we can be of any additional help to you in this regard.You may also consult our documentation guide for further examples in this regard.

Sample Code:


// Create a new instance of MailMessage class

MailMessage message = new MailMessage();

// Set sender information
message.setFrom(new MailAddress("from@domain.com", “Sender Name”, false));

// Add recipients
message.getTo().add("to@domain.com");

// Set subject of the message
message.setSubject(“New message created by Aspose.Email for Java”);

// Set Html body. It also contains tag with cid. cid = LinkedResource.ContentID
message.setHtmlBody("This line is in bold.

"

+ “This line is in blue color

” +

“Here is an embedded image.”);

// Add linked resource
LinkedResource res = new LinkedResource(“Add Embedded images to Email Message-001.png”, MediaTypeNames.Image.PNG);

res.setContentId(“companylogo”);

// Add Linked resource to the message’s Linked resource collection
message.getLinkedResources().addItem(res);

MapiMessage mapiMsg = MapiMessage.fromMailMessage(message);

mapiMsg.save(“MapiMsg.msg”);