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

Free Support Forum - aspose.com

Sending an email

Hi,

I've been using the .NET 2.0 System.Net.Mail class for a project I've been working on. One of the requirements is to send the email with Mail Sensitivity, which doesn't exist.

So I've downloaded Aspose.Network.Mail from the site to test it out. I've placed the dll as a reference inside my project.

I'm having troubles sending my email. First I just replaced the Microsoft Mail class with Aspose. The code was fine, and when I went to send an email it says SmtpClient username cannot be null. I didn't need to enter a username or password for Microsoft Mail class. When I added my ntlm username and password the error message I got was Authentication unsucessful (535). I don't really want to put a username and password in. Can someone see if my code is wrong somewhere as I cannot get it to work. Once I have proved that the dll works and I can get Mail Sensitivity working, then I'll have to put my case accross to the clients to purchase.

MailMessage Mail = new MailMessage(ConfigurationSettings.AppSettings["FromEmail"].ToString(), emailAddress);
Mail.Subject = "PREVIEW: " + subject;
Mail.HtmlBody = messageBody;
Mail.Sensitivity = MailSensitivity.Private;

SmtpClient client = new SmtpClient(ConfigurationSettings.AppSettings["SMTPServer"]);

//Added these lines for Aspose
client.Port = 25;
client.Username = "myUserName";
client.Password = "myPassword";
client.AuthenticationMethod = SmtpAuthentication.Ntlm;
//to here

client.Send(mail);

Through stepping through the code Mail.Sensitivity doesn't seem to change to Private either, but as I'm unable to send an email, I can't see if this is working either. Please Help.

Hi,

Thanks for considering Aspose.

Could you please try setting the authentication to none as below:

client.AuthenticationMethod = SmtpAuthentication.None;

You can change the mail sensitivity from MailMessage.Sensitivity property.

MailMessage msg = new MailMessage("from@domain.com", "to@domain.com", "subject", "body");

msg.Sensitivity = MailSensitivity.Private;

Thank you. So simple when you know how. :)