C# 通过发送邮件获取收据通知

C# 通过发送邮件获取收据通知,c#,email,C#,Email,在这里,我正在使用c#开发一个用于发送邮件的桌面应用程序。我想添加邮件读取通知。我使用了下面的代码,但它不起作用。-非常感谢您的帮助 我已经使用过,但不起作用: protected void btnSend_Click(object sender, EventArgs e) { //txtFrom.Text = "test.common@gmail.com"; try { MailMessage ms = new MailMessage();

在这里,我正在使用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;
    }
protectedvoidbtnsend\u单击(对象发送者,事件参数e)
{
//txtFrom.Text=“测试。common@gmail.com";
尝试
{
MailMessage ms=新的MailMessage();
ms.To.Add(txtAddr.Text);
ms.From=新邮件地址(txtFrom.Text);
ms.Subject=txtSubject.Text;
ms.Body=txtBody.Text;
ms.DeliveryNotificationOptions=
DeliveryNotificationOptions.OnFailure|
DeliveryNotificationOptions.OnSuccess|
DeliveryNotificationOptions。延迟;
ms.Headers.Add(“处置通知到“,”);
//if(FileUpload1.HasFile)
//{
//ms.Attachments.Add(新附件(
//FileUpload1.PostedFile.InputStream,FileUpload1.FileName));
//}
SmtpClient smtp=新SmtpClient();
smtp.Host=“smtp.gmail.com”;
//smtp.Host=“localhost”;
NetworkCredential cs=新的NetworkCredential(“测试”)。common@gmail.com", "123");
smtp.Credentials=cs;
smtp.EnableSsl=true;
smtp.Port=587;
smtp.Send(ms);
Literal1.Text=“您的邮件已发送…”;
}
捕获(例外情况除外)
{
Literal1.Text=例如消息;
}

它看起来不像Gmail支持个人账户的读取接收

摘自:

阅读收据仅适用于商业、教育和政府客户的谷歌应用程序。个人Gmail帐户中不提供阅读收据。请立即升级


“但不起作用:”-想详细说明一下吗?这比你以前的尝试要好:但请解释出哪里出了问题。为什么你的标题中有尖括号?你是否删除了它,然后再试一次?这应该是测试。common@gmail.com没有。你也尝试过非gmail地址吗?记住,它可能“不起作用”如果客户端不支持它。