Aspose.Email - Add Embedded Images to Email Message

// Set Html body. It also contains <img> tag with cid. cid = LinkedResource.ContentID
message.setHtmlBody("<b>This line is in bold.</b> <br/> <br/>"
        + "<font color=blue>This line is in blue color</font><br><br>" +
        "Here is an embedded image.<img src=cid:companylogo>");

// Add linked resource
LinkedResource res = new LinkedResource(dataPath + "Aspose.png", MediaTypeNames.Image.PNG);
res.setContentId("companylogo");

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


Download Source Code

For More Examples, Please Visit Aspose Docs

Last edited Jan 2, 2015 at 4:00 PM by shoaibkhan, version 1