Devo inviare posta usando la mia applicazione web. Dato sotto il codice che mostra l'errore The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM
. Aiutami a trovare una soluzione adeguata. Grazie.La risposta del server era: 5.7.57 SMTP; Il cliente non è stato autenticato per inviare posta anonima durante MAIL DAL
Codice:
protected void btnsubmit_Click(object sender, EventArgs e)
{
Ticket_MailTableAdapters.tbl_TicketTableAdapter tc;
tc = new Ticket_MailTableAdapters.tbl_TicketTableAdapter();
DataTable dt = new DataTable();
dt = tc.GetEmail(dpl_cate.SelectedValue);
foreach (DataRow row in dt.Rows)
{
string eml = (row["Emp_Email"].ToString());
var fromAddress = "emailAddress";
var toAddress = eml;
const string fromPassword = "*****";
string body = "Welcome..";
// smtp settings
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "smtp.office365.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
smtp.UseDefaultCredentials = false;
smtp.Timeout = 600000;
}
// Passing values to smtp object
smtp.Send(fromAddress, toAddress, subject, body);
}
}
}
perché non aumentare il timeout? –
Hai reso anonimo questo messaggio o stai effettivamente tentando di inviare su office.com con quel login? – fk2
@reshma, Quali modifiche hai apportato? Di fronte allo stesso problema. –