Quantcast
Channel: Exchange Server 2010 forum
Viewing all articles
Browse latest Browse all 8820

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.

$
0
0

 try
            {
                MailMessage mail = new MailMessage();
                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
                mail.From = new MailAddress("FROMXXXX@gmail.com");
                mail.To.Add("TOXXXX@gmail.com");
                mail.Subject = "Test Mail..!!!!";
                mail.Body = "mail with attachment";

                System.Net.Mail.Attachment attachment;
                attachment = new System.Net.Mail.Attachment(@"C:\Attachment.txt");
                mail.Attachments.Add(attachment);

                SmtpServer.Port = 587;
                SmtpServer.UseDefaultCredentials = true;
                SmtpServer.Credentials = new System.Net.NetworkCredential("userid", "Password");
                SmtpServer.EnableSsl = true;
                SmtpServer.Send(mail);

               }

Catch(Exception exception)

{}

               

When i m run this part of code it throw an Ecxeption                                                                  Given Below is the Error..     The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.


Bikky Kumar



Viewing all articles
Browse latest Browse all 8820

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>