Click here to Skip to main content
Sign Up to vote bad
good
See more: ASP.NETC#4.0VB.NET
HI guys
I am using
System.Net.Mail;
to send mails in windows application .
all my credentials are right but i am getting "Authentication failed" Error message..

I have tried a lot but it didn't worked .. Can anyone Help me pls
 
this is the error message i am getting in depth...

{System.Net.Mail.SmtpException: Authentication failed.
at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)


here is the code:
SmtpClient client = new SmtpClient();
                MailMessage msg = new MailMessage();
               
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                client.EnableSsl = false;
                client.Host =  "mail.xx.com";
                client.Port =  25;
 
                System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("username@xx.com", "pwd");
                client.UseDefaultCredentials = false;
                client.Credentials = credentials;
                msg.From = new MailAddress("ams@xx.com",System.Text.Encoding.UTF8);
                msg.To.Add(xx@gmail.com);
                msg.Subject = Subject;
                msg.SubjectEncoding = System.Text.Encoding.UTF8;
                msg.Priority = MailPriority.High;
                msg.Body = Body;
                msg.BodyEncoding = System.Text.Encoding.UTF8;
                msg.IsBodyHtml = true;
 
                msg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
                client.Send(msg);
Thanks In advance
 
[Edit]Code block added[/Edit]
Posted 27 Oct '12 - 0:16
Edited 27 Oct '12 - 5:20
ProgramFOX55.3K

Comments
kkakadiya - 27 Oct '12 - 6:21
hi, Please check username and password you are using for the same...
Hari Chandra Prasad Ravuri - 27 Oct '12 - 6:27
hello kkakadiya All credentials are correct sir .but still i am getting that error
xErvender - 27 Oct '12 - 10:15
can you post the code?
Hari Chandra Prasad Ravuri - 27 Oct '12 - 11:18
ok i have posted the code pls check it

2 solutions

Without your code to check how you are doing it, we can't rally help much.
However, this works: Sending an Email in C# with or without attachments: generic routine.[^] so it might be worth checking how you do it against that.
  Permalink  
Hi
 
 
MailMessage message = new MailMessage();
 
message.From = new MailAddress("userid@yahoo.com");
message.To.Add(new MailAddress("ngqandu.anele@gmail.com"));
message.Subject = subject.Text;
message.Body = body.Text;
 
SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential ("userid@yahoo.com", "password");
 
                client.Port = 587;
                client.Host = "smtp.mail.yahoo.com";
                client.EnableSsl = false;
                try
                {
                    client.Send(message);
                }
                catch (Exception ex)
                {
MessageBox.Show
            (ex.Message,"Information",MessageBoxButton.OK,MessageBoxImage.Information);
                }
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 325
1 Mohammed Hameed 123
2 Sergey Alexandrovich Kryukov 115
3 Santhosh G_ 103
4 Ron Beyer 89
0 Sergey Alexandrovich Kryukov 8,286
1 OriginalGriff 6,561
2 CPallini 3,533
3 Rohan Leuva 2,703
4 Maciej Los 2,234


Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 27 Oct 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid