Multipart |
public string ReportType { get; set; }
Exception | Condition |
---|---|
ArgumentNullException | value is null. |
ObjectDisposedException | The MultipartReport has been disposed. |
Gets or sets the type of the report.
The report type should be the subtype of the second MimeEntity of the multipart/report.
public void ProcessDeliveryStatusNotification (MimeMessage message) { var report = message.Body as MultipartReport; if (report == null || report.ReportType == null || !report.ReportType.Equals ("delivery-status", StringComparison.OrdinalIgnoreCase)) { // this is not a delivery status notification message... return; } // process the report foreach (var mds in report.OfType<MessageDeliveryStatus> ()) { // process the status groups - each status group represents a different recipient // The first status group contains information about the message var envelopeId = mds.StatusGroups[0]["Original-Envelope-Id"]; // all of the other status groups contain per-recipient information for (int i = 1; i < mds.StatusGroups.Length; i++) { var recipient = mds.StatusGroups[i]["Original-Recipient"]; var action = mds.StatusGroups[i]["Action"]; if (recipient == null) recipient = mds.StatusGroups[i]["Final-Recipient"]; // the recipient string should be in the form: "rfc822;user@domain.com" var index = recipient.IndexOf (';'); var address = recipient.Substring (index + 1); switch (action) { case "failed": Console.WriteLine ("Delivery of message {0} failed for {1}", envelopeId, address); break; case "delayed": Console.WriteLine ("Delivery of message {0} has been delayed for {1}", envelopeId, address); break; case "delivered": Console.WriteLine ("Delivery of message {0} has been delivered to {1}", envelopeId, address); break; case "relayed": Console.WriteLine ("Delivery of message {0} has been relayed for {1}", envelopeId, address); break; case "expanded": Console.WriteLine ("Delivery of message {0} has been delivered to {1} and relayed to the the expanded recipients", envelopeId, address); break; } } } }