邮件服务器问题

时间:2017-03-29 22:25:42

标签: .net

我在我的代码中整合邮件。我使用mail smtp.gmail.com作为smtp服务器。 我正在尝试获取邮件的发送状态,但我收到了以下错误

  

找不到支持的送货状态通知编组

下面是我正在使用的代码。

SmtpMail oMail = new SmtpMail("TryIt");
SmtpClient oSmtp = new SmtpClient();

// Set sender email address, please change it to yours
oMail.From = "akshaz@tekinspirations.com";

// Set recipient email address, please change it to yours
oMail.To = to;

// Set email subject
oMail.Subject = subject;

// Set email body
oMail.TextBody = message;

// Your SMTP server address
SmtpServer oServer = new SmtpServer("smtp.gmail.com");

// User and password for ESMTP authentication, if your server doesn't require
// User authentication, please remove the following codes.
oServer.User = "xyz@tekinspirations.com";
oServer.Password = "xyz";
// If your smtp server requires SSL connection, please add this line
oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
// Set 25 port, if your server uses 587 port, please change 25 to 587
oServer.Port = 25;
// Set TLS connection
//oServer.ConnectType = SmtpConnectType.ConnectTryTLS;
// Request read receipt
oMail.ReadReceipt = true;
oMail.DeliveryNotification = DeliveryNotificationOptions.OnFailure | DeliveryNotificationOptions.OnSuccess;
// Request both failure and success report
try
{
    // Console.WriteLine("start to send email ...");
    oSmtp.SendMail(oServer, oMail);

    // Console.WriteLine("email was sent successfully!");
}
catch (Exception ep)
{
    //Console.WriteLine("failed to send email with the following error:");
    // Console.WriteLine(ep.Message);
    //SqlConnection con = new SqlConnection("Data Source=.; Initial Catalog=db_EmailTest;Integrated Security=True;");
    // con.Open();
    // SqlCommand cmd = new SqlCommand("Update tbl_Email set Status=1 Where EmailID="+ to, con);
    //cmd.ExecuteNonQuery();
    string s = ep.Message;
}

0 个答案:

没有答案