Embedded pictures not displayed? BASE tag can be the cause.

When using a method like MailMessage.GetHtmlAndSaveRelatedFiles or MailMessage.SaveHtmlAndRelatedFiles to display HTML e-mail with embedded pictures, you can sometimes face an issue that the pictures are not get displayed. The common reason is the presence of BASE tag in the HTML source.

This issue can be fixed easily. Just make sure that you always set a working folder where embedded pictures will be saved to some absolute path. For instance:

// msg is a MailMessage instance
msg.Parser.WorkingFolder = "C:\\Temp";
html = msg.GetHtmlAndSaveRelatedFiles();

This way all embedded pictures will have filenames with full path and won’t depend on relative paths which are affected by BASE tag.

Embedded pictures not displayed? BASE tag can be the cause.

One thought on “Embedded pictures not displayed? BASE tag can be the cause.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s