Recently we faced an issue in receiving mails from
same (sender) domain email account but using different SMTP server. Mail body has few
resources like GIF, JPEG and they are loaded with AlternateView (System.Net.Mail.MailAddress.AlternateViews) parameter with linked resources.
Ex: sender@example.com sends mail to recevier@example.com using a different SMTP server (ex: mailserver.com) i.e. not using example.com (SMTP) domain.
Result of this scenario: Receiver did not receive any email.
In mail body, resources
can be loaded with the below options.
- Absolute path (http://www.nehemiahj.com/image.jpg)
- Relative path (/image.jpg)
- Resources (System.Resources.ResourceManager)
The mail could be blocked due
to Exchange Intelligent Message Filter as in Microsoft
Exchange server. Also to note that emails to other providers like GMAIL, YAHOO were
successful.
When we remove all the resources
in the email body, email reached the destination mail boxes but without any
resources. Initially, to get
the resource image, the below line was used.
LinkedResource image = new
LinkedResource(imageResource) { ContentId =
contentId };
view.LinkedResources.Add(image);
message.AlternateViews.Add(view);
Solution:
We did a small tweak
to add proper content type for the resource which apparently resolved the
issue.
LinkedResource image = new
LinkedResource(imageResource, MediaTypeNames.Image.Gif)
{ ContentId = contentId };
view.LinkedResources.Add(image);
message.AlternateViews.Add(view);
By
this way, we are explicitly defining the content type of the resource. Of-course,
we can simply disable the filter in the exchange server to receive the email but
amending the resources in the mail body with proper content type has been
skipped by the exchange filters.
No comments:
Post a Comment