Hello,
We are using Aspose Email V1.0.0.0 and are currently facing an issue when sending emails to addresses @laposte.net.
The mail doesnt’t display properly on the webmail of this particular mail provider.
We had some issued with this provider that we were able to fix (we normally use text and HTML alternate views to send email and we found out that the only way to send properly email to this provider was to set directly the HTML into the message body and attach the LinkedResources directly to the message.
The problem it that this hack doesn’t work when we add attachments on the message. We are facing the same problem as before : the email won’t display properly.
I tried with version 2.0 and it doesn’t seem to solve my problem.
I tried also with version 2.1 but got an exception when trying to make SmtpClient mySmtp = new SmtpClient(“smtpServer.mycompany.com”)
. This code threw a configuration exception everytime I tried to use it.
Could you please help us solving this problem?
You will find below a code sample that should allow you to reproduce the problem
static void SendMail2()
{
Document wordDoc = new Document(“C:\temp\mydoc.doc”);
MemoryStream htmlStream = new MemoryStream();
string imgsDir = “C:\temp\images”;
wordDoc.SaveOptions.HtmlExportImagesFolder = imgsDir + “\”;
wordDoc.Save(htmlStream, SaveFormat.Html);
htmlStream.Position = 0;
StreamReader htmlStreamReader = new StreamReader(htmlStream);
string bodyHtml = htmlStreamReader.ReadToEnd();
htmlStreamReader.Close();
htmlStream.Close();
//Initialize mail message (object + addresses)
MailMessage M = new MailMessage();
//Transform from and to addresses as aspose email mail addresses
MailAddress pAddFrom = new MailAddress("me@mycompany.com", “MyDisplayName”);
MailAddress pAddTo = new MailAddress("myAddress@laposte.net");
M.From = pAddFrom;
M.To.Add(pAddTo);
M.Subject = “Email Subject”;
//Replace the links to the images in the HTML body to be able to embed them in the email
List<Aspose.Email.Mail.LinkedResource> htmlLinkedResources = new List<Aspose.Email.Mail.LinkedResource>();
foreach (string img in Directory.GetFiles(imgsDir))
{
if (!img.EndsWith(".db"))
{
string cidName = System.Web.HttpUtility.HtmlEncode(Path.GetFileNameWithoutExtension(img));
bodyHtml = bodyHtml.Replace(System.Web.HttpUtility.HtmlEncode(img), “cid:” + cidName);
System.IO.StreamReader reader = new System.IO.StreamReader(img);
Aspose.Email.Mail.LinkedResource image = new Aspose.Email.Mail.LinkedResource(img, “image/png”);
image.ContentId = Path.GetFileNameWithoutExtension(img);
htmlLinkedResources.Add(image);
}
}
//Only construct the HTML body of the email and attach images directly to the message for [laposte.net](http://laposte.net/) emails
M.HtmlBody = bodyHtml;
foreach (Aspose.Email.Mail.LinkedResource Image in htmlLinkedResources)
{
M.LinkedResources.Add(Image);
}
foreach (string pAttachment in Directory.GetFiles(“C:\temp\attachmentsDirectory”))
{
M.Attachments.Add(new Attachment(pAttachment));
}
SmtpClient smtp = new SmtpClient(“[mail.mycompany.com](http://mail.mycompany.com/)”);
smtp.Send(M);
}
Thanks in advance for you help