这里我使用c#开发一个桌面应用程序来发送邮件。在那我想要添加邮件阅读通知。我使用下面的代码,但它不起作用。 - 非常感谢任何帮助。
我使用它但不起作用:
protected void btnSend_Click(object sender, EventArgs e)
{
//txtFrom.Text = "test.common@gmail.com";
try
{
MailMessage ms = new MailMessage();
ms.To.Add(txtAddr.Text);
ms.From = new MailAddress(txtFrom.Text);
ms.Subject = txtSubject.Text;
ms.Body = txtBody.Text;
ms.DeliveryNotificationOptions =
DeliveryNotificationOptions.OnFailure |
DeliveryNotificationOptions.OnSuccess |
DeliveryNotificationOptions.Delay;
ms.Headers.Add("Disposition-Notification-To", "<test.common@gmail.com>");
//if (FileUpload1.HasFile)
//{
// ms.Attachments.Add(new Attachment(
// FileUpload1.PostedFile.InputStream, FileUpload1.FileName));
//}
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
//smtp.Host = "localhost";
NetworkCredential cs = new NetworkCredential("test.common@gmail.com", "123");
smtp.Credentials = cs;
smtp.EnableSsl = true;
smtp.Port = 587;
smtp.Send(ms);
Literal1.Text = "Your message has been sent...";
}
catch (Exception ex)
{
Literal1.Text = ex.Message;
}
答案 0 :(得分:0)