如何知道电子邮件状态(mailject)

时间:2014-07-28 10:07:25

标签: c# email sendmail mailjet

我正在使用Mailjet SMTP发送电子邮件。现在,我想验证是否发送了电子邮件。 Mailjet有这个email status,但我怎么能访问这些信息? Mailjet也有这个API,但这在php ...

如果我使用DeliveryNotificationOptions可以解决此问题? 像这样:

mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess | DeliveryNotificationOptions.OnFailure | DeliveryNotificationOptions.Delay;

1 个答案:

答案 0 :(得分:0)

我可以与API Mailjet沟通,如:

Uri address = new Uri("http://api.mailjet.com/0.1/reportEmailsent");
HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
request.Method = "GET";
request.KeepAlive = true;
request.Headers.Add("apiKey", "numberapiKey");
request.Headers.Add("secretKey", "numbersecretKey");
request.Credentials = new NetworkCredential("apiKey", "serialKey");
request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
request.Accept = "application/x-www-form-urlencoded; charset=UTF-8";

现在得到回应:

// Get response
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
   Stream ResponseStream = null;
   ResponseStream = response.GetResponseStream();
   int responseCode = (int)response.StatusCode;
   string responseBody = ((new StreamReader(ResponseStream)).ReadToEnd());
}