尝试通过以下代码发送邮件时抛出以下异常:
SMPT server requires a secure connection or the client was not authenticated. The server response was 5.5.1. Authentication required
C#
string E_mail_ID = "hidden";
try
{
SmtpClient gmail_client = new SmtpClient("smtp.gmail.com");
gmail_client.Port = 587;
gmail_client.EnableSsl = true;
gmail_client.Timeout = 100000;
gmail_client.DeliveryMethod = SmtpDeliveryMethod.Network;
gmail_client.UseDefaultCredentials = false;
gmail_client.Credentials = new NetworkCredential("hidden", "hidden");
MailMessage msg = new MailMessage();
msg.From = new MailAddress("hidden");
msg.To.Add(E_mail_ID.Trim());
msg.Body = "Request for quotation from Jeet fly ash products, a unit of Vidya shakti niyas";
msg.Attachments.Add(new Att![enter image description here][1]achment(pdfFile));
gmail_client.Send(msg);
MessageBox.Show("RFQ sent to vendor successfully");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}