1

I want to select file and send to employees. employee's(recipient) email I am reading from excel. Sender's email is set to my code.

MailMessage mail = new MailMessage();
mail.Attachments.Add(new System.Net.Mail.Attachment(attach));
mail.To.Add(sendmail);
mail.From = new MailAddress(SenderEmail);
mail.Subject = "Payroll";
string body = "Hi, payroll";
mail.Body = body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("sendermail", "pwd");
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Send(mail);

Now I want to read sender's email & password from a textbox,and pass. Now error occuring like this

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

I coded smtpclient host as gmail and corresponding port. But I want to send from other account means in yahoo,live etc.. How can it possible? But even gmail is also giving error.Can anybody help? error is getting when reading from textbox

4

0 回答 0