尝试向我的电子邮件发送TextBox
值时,我一直收到此异常。这是我到目前为止的代码,我已经搞砸了很多。我不仅收到此消息,而且还没有收到此TextBox
的电子邮件。我也在使用C#
和ASP.NET
。单击按钮时,我也会收到消息。
protected void donateSubmit_onClick(object sender, EventArgs e)
{
using (MailMessage message = new MailMessage())
{
message.To.Add(new MailAddress("jenlc0620@gmail.com"));
message.CC.Add(new MailAddress("moeplamen@gmail.com"));
message.Subject = "Charity Inquiry";
message.Body = donateBox.Text.ToString();
SmtpClient client = new SmtpClient("smtp.gmail.com", 456);
client.UseDefaultCredentials = false;
System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("email","password");
client.Credentials = credentials;
client.Host = "127.0.0.1";
client.EnableSsl = true;
try
{
client.Send(message);
}
catch (Exception ex)
{
Console.WriteLine(ex); //Should print stacktrace + details of inner exception
if (ex.InnerException != null)
{
Console.WriteLine("InnerException is: {0}", ex.InnerException);
}
}
}
donateBox.Text=String.Empty;
}