简体   繁体   English

如何检查电子邮件是否已成功发送?

[英]How to check if the email have sent successfully or not?

See title. 见标题。 Since SmtpClient.Send has no return value, I want to know how I can be sure that the E-Mail was successfully sent. 由于SmtpClient.Send没有返回值,我想知道如何确保电子邮件已成功发送。

Here is the code I have until now and it works fine (it is from google): 这是我到目前为止的代码,它工作正常(来自谷歌):

private void sendMail(string strToAddress, string strFromAddress, string strSubject, string strBody)
{
    // new instance of MailMessage
    MailMessage mailMessage = new MailMessage();

    // Sender Address
    mailMessage.From = new MailAddress(strFromAddress);

    // Recepient Address
    mailMessage.To.Add(new MailAddress(strToAddress));

    // Subject 
    mailMessage.Subject = strSubject;

    // Body
    mailMessage.Body = strBody;

    // format of mail message
    mailMessage.IsBodyHtml = true;

    // new instance of Smtpclient
    SmtpClient mailSmtpClient = new SmtpClient("mail.lablabal.com");

    // mail sent
    mailSmtpClient.Send(mailMessage);
}

If there's an immediate error, SmtpClient::Send() will throw an exception . 如果出现立即错误, SmtpClient::Send()将抛出异常 There's no way to "track" the email (unless there's some confirmation link to click or whatever). 没有办法“跟踪”电子邮件(除非有一些确认链接点击或其他)。 You won't keep a server connection till the mail is received, only till your smtp server passed it successfully (or failed doing so). 在收到邮件之前,您不会保持服务器连接,直到您的smtp服务器成功通过它(或者这样做失败)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Sendgrid IEmailSender 实现,捕获异常,检查一个 email 是否发送成功 - Sendgrid IEmailSender implementation, catch an exception, check if an email was sent successfully 如何检查邮件是否已成功发送 - How to check if the mail has been sent successfully 一种使用EmailComposeTask确定电子邮件是否已成功发送的方法 - A way to determine if the email was sent successfully using EmailComposeTask 如何在 C# 中检查生产者发送的消息是否已成功到达 Kafka 服务器? - How to check in C # that a message sent by a producer has successfully reached the Kafka server? 在尝试块中成功发送了Smtp电子邮件的弹出消息 - Popup message for Smtp email is sent successfully in try block 成功发送电子邮件后,C#Outlook删除事件? - C# Outlook Remove event when email sent successfully? 为什么我的 email 发送成功但没有发送到收件人的收件箱? - Why my email was successfully sent but was not delivered to the recepient's inbox? 如何验证电子邮件是否已发送 - How to validate if email sent 如何使用MailKit IMap成功发送邮件? - How to get mail sent successfully with MailKit IMap? “阅读”收据是否具有“父”发送电子邮件的标识符 - Do Read receipts have an identifier for the “parent” sent email
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM