Skip to content

Add Embedded Images to Email Message

shoaibkhan-aspose edited this page Jan 5, 2015 · 1 revision

Aspose.Email

// 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

Clone this wiki locally