Issue with Aspose.Email on emails


We are using Aspose Email V1.0.0.0 and are currently facing an issue when sending emails to addresses

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(“”). 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();



//Initialize mail message (object + addresses)

MailMessage M = new MailMessage();

//Transform from and to addresses as aspose email mail addresses

MailAddress pAddFrom = new MailAddress("", “MyDisplayName”);

MailAddress pAddTo = new MailAddress("");

M.From = pAddFrom;


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);




//Only construct the HTML body of the email and attach images directly to the message for []( emails

M.HtmlBody = bodyHtml;

foreach (Aspose.Email.Mail.LinkedResource Image in htmlLinkedResources)




foreach (string pAttachment in Directory.GetFiles(“C:\temp\attachmentsDirectory”))


M.Attachments.Add(new Attachment(pAttachment));


SmtpClient smtp = new SmtpClient(“[](”);



Thanks in advance for you help

Hi Olivier,

Thank you for using Aspose.Email and we are sorry for the inconvenience you are facing.

In order to investigate this issue further, we would request you to please provide some supporting information and material in this regard. We would like to know the difference between the formatting with and without attachments added to the email. You can provide us some screenshots for both the cases that we can use for further testing.

It will also be of great help if you can provide us the source word document and images, that you are using, to reproduce the issue at our end. If you find that there are some specific attachment files that are raising this issue, please provide the attachments as well in that case, otherwise we can use other files at our end as attachments. We will investigate the issue further and assist you as soon as possible.

Moreover, we are investigating the “Configuration Exception” issue and will share our findings with you soon. Meanwhile, you can use the work around of defining the SmtpClient object and settings its parameters outside constructor as follow:

//Create an instance of SmtpClient Class

SmtpClient client = new SmtpClient();

//Specify your mailing host server

client.Host = "";

//Specify your mail user name

client.Username = "username";

//Specify your mail password

client.Password = "password";

//Client.Send will send this message


Hi Kashif,

Thank you for your answer.
I tried your workaround for the SmtpClient constructor with V2.1.0 but unfortunately it didn’t work.
You will find attached a zip file containing :
- SmtpClientConstructorExceptionStack.txt → Stack of the exception I’m getting when trying to Make a New SmtpClient() with V2.1.0.
- Attachment.doc → An attachment I’m using for my tests but the bug happens using any kind of attachment.
- EmailBody.doc → the word document I use as the email body but I’m able to reproduce the bug with any other word document as email body.
- EmailResultWithAttachments.png → The result of the email displayed in webmail when we add the attachment to the email.
- EmailResultWithoutAttachments.png → The result of the email displayed in webmail when the email has no attachments.

Do not hesitate to let me know if you need more information to investigate this problem.



Thank you for the feedback.

We appreciate your cooperation in providing the required information. As this issue is specific to the mail box, it is difficult for us to reproduce this issue at our end, as we don’t have an account on this mail box. Is it possible for you to setup a test account for us on this mailbox and provide us login credentials, so that we can carry out our tests?

Moreover, we further investigated the exception that is raised while defining a new SmtpClient object with V2.1.0 and observed this as well at our end. We will look into this and provide further assistance or a solution in next release version if it’s a bug. For the time being, please add a reference to System.Configuration to your project. This should solve the problem for now.


I created an email account at for you.
login :
password : testAspose
You can access this webmail on

Thank you for the solution you suggested for the issue with V2.1.0 but I already have a reference to System.Configuration in my project and it doesn’t work.
Is there any configuration I could do somewhere else to solve the problem?


Thank you for providing the test account credentials.

After further investigation, I was able to observe the issue as you have mentioned. This seems to be an issue with specific mail server only, as if I send the email to my Gmail or any other server, the email is displayed properly as intended. I have forwarded these details along with the test account credentials to our development team for further investigation. In this respect, we would request you to please keep this test account enabled so that our development team can use it for investigating the issue. We will update you here as soon as we have further information in this regard. The issue has been logged as: NETWORKNET-33463 in our issue tracking system.

For the System.Configuration exception that you are getting, can you please tell us the .NET Framework version that you are using? I have also attached here a test application that I used to send email to the test account using Aspose.Email for .NET v 2.1.0. Please try it at your end and see if you are able to find it working and let us know your feedback then.

Hi Kashif,

I’ve tried to use your executable sample and it’s working fine on my computer.
I’m not sure but I guess that the main difference is that I’m using Aspose Email from a web application. It seems to be the reason I’m getting the error.
If you have a simple way to do so, could you check if you produce the error I’m getting?
To answer your question, I’m using .NET 3.5.



Thank you for using Aspose.Email and providing us feedback.

We received similar comments from another user as well and have already logged an issue in this regard as NETWORKNET-33475. I have linked this thread also to the same issue, so that when it is fixed, you will get an automatic notification here. We appreciate your patience in this regard.


Thank you for being patient towards the resolution of this issue.

We have fixed this issue of SMTP functionality with web projects. Please download and use the fix for Aspose.Email for .NET and let us know your feedback.

Hi Kashif!

Thank you for your feedback. The problem is solved regarding the SMTP issue in web context.
Have you any update regarding the “” issue?



You are welcome.

We are glad to inform you that the issue related to “” has been fixed and hopefully we will provide a fix in the upcoming release of Aspose.Email for .NET We will update you here once the product release is in place and appreciate your patience in this regard.

Hi Kashif,

Is the release of V2.3 already planned?



I would like to share with you that we do monthly releases, usually at the end of every month. We do have planned release of Aspose.Email for .NET 2.3.0 at the end of this month and will notify you here once the release is in place.

The issues you have found earlier (filed as NETWORKNET-33475;NETWORKNET-33463) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Hi Olivier,

We have investigated the issue with emails formatting and here are our findings. email client represents emails incorrectly if:

  1. email contains html part with embedded image;
  2. email contains attachment
  3. email does not contain email part with Content-Type: multipart/alternative

For correct formatting of the emails on, you should use AlternateViews as shown in the code below:

string from = "";
string to = "";
string html = @"<h1>This is big header!!!</h1>
<p>first paragraph</p>
<p>second paragraph</p>";
MailMessage target = new MailMessage();
target.From = from;
target.To = to;
target.Subject = "NETWORKNET_33463 " + Guid.NewGuid().ToString();
target.AlternateViews.Add(AlternateView.CreateAlternateViewFromString("text view", new ContentType("text/plain")));
target.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(html, new ContentType("text/html")));
string imgPath = "image001.gif";
LinkedResource image = new LinkedResource(imgPath, "image/" + Path.GetExtension(imgPath).ToLower());
image.ContentId = Path.GetFileNameWithoutExtension(imgPath);
string attPath = "Attachment.doc";
target.Attachments.Add(new Attachment(attPath));
using (SmtpClient smtpClient = new SmtpClient())
    //add SMTP client settings here...and send the message

Hi Kashif!

I just performed a quick test with the new version and it seems to be working perfectly.
Thank you very much for fixing it quickly.


Hi Olivier,

Thank you for the feedback.

It’s good to know that your problem is solved now. If you have any other query/inquiry, please feel free to contact us. We will be glad to help you out as soon as possible.

Hello again Kashif,

I currently have a license issue with this version.
I reported this issue on septembre 3rd and it was fixed in a release at the end of October.
During this period, our license expired (October 6th) and I am now getting an error when registering the license as I am not allowed to use a product that was released after our license expiration.
Is there any chance you could provide us with a patch containing this fix?


Hi Olivier,

Thanks for writing to Aspose.Email and I am sorry for the delayed response.

I am afraid to inform that its not possible to extend the licence and you may get new licence to continue using updates of the Aspose.Email.

We are really sorry for any inconvenience caused to you.

Hello Kashif,

We recently migrated to Aspose.Words 11.11 and I’m facing a regression with my email sending. Images contained in the word document are not at their proper place whatever email provider I’m sending an email to.
Could you please investigate this issue?