We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Embedded images do not display in iOS mail app and gmail (in IE)

Hi,
We are using the linkedresource class to embed an image in a mail message. A very simple mail message with a piece of text and an image.
When this is sent and opened in outlook the image shows up, but when the same message is sent to an email address configured to be opened by the default iOS mail app on an ipad or iphone, the image does not show (instead the broken image logo with a x sign is displayed).

When sent to a gmail address, if i open gmail in firefox - the image does get displayed but when the same email is opened in IE, it shows the same broken image logo.

Is there any setting that i might be missing to make this work ? Please advise.

Jaideep,


Thank you for writing to Aspose support team.

I have tested this scenario at my end using the latest version of Aspose.Email for .NET 4.2.0 and was unable to face any issue as you have mentioned. The received email is displayed fine on my iPad device (screenshot attached) as well as in both browsers i.e. Internet Explorer 11 and Firefox (image attached). Could you please give it a try using this latest version and let us know your feedback? Following is the sample code that I have tried at my end:

Sample Code:

//Create an instance of the MailMessage
class
<o:p></o:p>

MailMessage mail = new MailMessage();

string strFrom = "from@gmail.com";

string strTo = "to@gmail.com";

//Set the addresses

mail.From = new MailAddress(strFrom);

mail.To.Add(strTo);

//Set the content

mail.Subject = "This is an email";

//Create the plain text part

//It is viewable by those clients that don't support HTML

AlternateView plainView = AlternateView.CreateAlternateViewFromString("This is my plain text content", null, "text/plain");

//Create the HTML part.

AlternateView htmlView = AlternateView.CreateAlternateViewFromString("Here is an embedded image.", null, "text/html");

//create the LinkedResource (embedded image)

LinkedResource logo = new LinkedResource(@"S.png", MediaTypeNames.Image.Png);

logo.ContentId = "companylogo";

//Add the LinkedResource to the appropriate view

mail.LinkedResources.Add(logo);

mail.AlternateViews.Add(plainView);

mail.AlternateViews.Add(htmlView);

//mail.Save(@"EmbeddedImage.msg", MailMessageSaveType.OutlookMessageFormatUnicode);

SmtpClient client = new SmtpClient("smtp.gmail.com", 587, "username", "pwd");

client.EnableSsl = true;

mail.Subject = "Subject 1 2 3 4 5";

client.Send(mail);