Embedding images

Top  Previous 

The HtmlEmailMessage class allows you to embed inline images into your HTML content.  An inline image is different than a normal image in that an inline image is included as part of the email message itself rather than issuing a separate HTTP request to the server to obtain the image file.  The result is that there will not be a delay in rendering when loading the HTML message part.  To embed an image in an HTML part you can use the Embed method.  Images may be embedded using either a URL or from a local file.

 

Example

 

This example demonstrates adding an image using a URL reference.  The ID used for the inline image must match the ID used in the HTML code.

 

[C#]

 

message.SetHtmlBody("<html><body><img src=\"cid:12345\"><br>this is the html body</body></html>");

message.Embed("http://www.domain.com/image.gif","12345");

 

[Visual Basic]

 

message.SetHtmlBody("<html><body><img src=\"cid:12345\"><br>this is the html body</body></html>")

message.Embed("http://www.domain.com/image.gif","12345")

 

Example

 

This example demonstrates adding an image using a local file reference.  The ID used for the inline image must match the ID used in the HTML code.

 

[C#]

 

message.SetHtmlBody("<html><body><img src=\"cid:12345\"><br>this is the html body</body></html>");

message.Embed(new FileInfo("image.gif"),"12345");

 

[Visual Basic]

 

message.SetHtmlBody("<html><body><img src=\"cid:12345\"><br>this is the html body</body></html>")

message.Embed(New FileInfo("image.gif"),"12345")

 

 





Home | Company | Products | Solutions | Purchase | Support | Services | Blog

© 2021 JSCAPE LLC