0 votes

I tried sending email from Gmail account and able to send the email successfully and save the email in my sent items .But,i got stuck when I try to send email from my Office account ,I am facing some issue .it's able to connect with the server but not able to authenticate if user I'd and password is provided.

 MailBuilder builder = new MailBuilder();
 builder.From.Add(new MailBox("ajayara@trimaxamericas.com", "Ashu"));
 builder.To.Add(new MailBox("Ashishjr3@gmail.com", "Jayara"));
 builder.Subject = "Test";
 builder.Text = "This is plain text message.";

 IMail email = builder.Create();

 using (Smtp smtp = new Smtp())
 {
     smtp.Connect("webmail.dataglove-us.com",25); 
     smtp.UseBestLogin("Ajayara@trimaxamericas.com", "*******");
     ISendMessageResult result = smtp.SendMessage(email);
     if (result.Status == SendMessageStatus.Success)
     {

     }

     smtp.Close();
 }

can you please suggest something?

by
What is the exact error message and stack trace?

1 Answer

0 votes

We can't really help you if you are using incorrect user and password.

One thing: consider using:

smtp.Connect("webmail.dataglove-us.com");  // no port => default 587

-or-

smtp.ConnectSSL("webmail.dataglove-us.com"); // for SSL/TLS

Consider contacting your server administrator for authentication details.

by (297k points)
yes your are right ,my server port no is 25 so i changed code. now i am getting error The remote certificate is invalid according to the validation procedure
If you get “The remote certificate is invalid according to the validation procedure” exception while trying to establish SSL/TLS connection, most likely your server certificate is self-signed or you are using incorrect host name to connect:

https://www.limilabs.com/blog/the-remote-certificate-is-invalid-according-to-the-validation-procedure

You can always accept invalid certificate (bad thing to do) using this code:
client.ServerCertificateValidate += (sender, args) => args.IsValid = true;
can you please help me to resolve this out.i already have this link but couldn't understand anything from there.
This article is rather clear, what exactly you have problems understanding?
...