ResultDsnStructure Property |
DsnAttachment object representing
RFC 1894 DSN attachment to this DSN message.
Namespace: MailBee.BounceMailAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public DsnAttachment DsnStructure { get; }
Public ReadOnly Property DsnStructure As DsnAttachment
Get
Property Value
Type:
DsnAttachmentA reference to the
DsnAttachment object containing the DSN attachment for the given
DSN message, or a null reference (
Nothing in Visual Basic) if the DSN attachment is missing in the DSN message.
Remarks
Most frequently used property of
DsnAttachment object is
OriginalEnvelopeID which
allows you to get the tracking ID of the original e-mail message. You can assign tracking ID to outgoing messages
using
Smtp.DeliveryNotification.TrackingID property.
Then, when a bounce message arrives, you can easily match it to the original message you sent earlier using tracking ID
provided that you create unique tracking ID for every message sent.
Examples This sample displays the DSN attachment and the original message part of the message.
It's assumed the e-mail samples are .EML files located in C:\Temp\IncomingMail folder.
The template database is stored in C:\Temp\BounceDatabase\all.xml file.
using System;
using System.IO;
using MailBee.Mime;
using MailBee.BounceMail;
class Sample
{
static void Main(string[] args)
{
DeliveryStatusParser parser = new DeliveryStatusParser (@"C:\Temp\BounceDatabase\all.xml", true);
string[] files = Directory.GetFiles(@"C:\Temp\IncomingMail", "*.eml");
MailMessage msg = new MailMessage();
foreach (string file in files)
{
msg.LoadMessage(file);
Result result = parser.Process(msg);
Console.WriteLine("\r\nProcessing of message with filename: " + file);
if (result == null || (result.OriginalMessage == null && result.DsnStructure == null))
{
Console.WriteLine("------------------------------------------------------");
Console.WriteLine("This message doesn't have DSN & original message part.");
Console.WriteLine("------------------------------------------------------");
}
else
{
if (result.OriginalMessage != null)
{
Console.WriteLine("----------------- Original message part --------------");
Console.WriteLine(result.OriginalMessage.RawHeader);
Console.WriteLine(result.OriginalMessage.BodyPlainText);
Console.WriteLine("------------------------------------------------------");
}
if (result.DsnStructure != null)
{
Console.WriteLine("---------------------- DSN part ----------------------");
Console.WriteLine(result.DsnStructure.ToString());
Console.WriteLine("------------------------------------------------------");
}
}
}
}
}
Imports System.IO
Imports Microsoft.VisualBasic
Imports MailBee.Mime
Imports MailBee.BounceMail
Class Sample
Shared Sub Main(ByVal args() As String)
Dim parser As DeliveryStatusParser = New DeliveryStatusParser("C:\Temp\BounceDatabase\all.xml", True)
Dim files() As String = Directory.GetFiles("C:\Temp\IncomingMail", "*.eml")
Dim msg As MailMessage = New MailMessage
For Each file As String In files
msg.LoadMessage(file)
Dim result As Result = parser.Process(msg)
Console.WriteLine(ControlChars.CrLf & "Processing of message with filename: " & file)
If result Is Nothing Or (result.OriginalMessage Is Nothing And result.DsnStructure Is Nothing) Then
Console.WriteLine("------------------------------------------------------")
Console.WriteLine("This message doesn't have DSN & original message part.")
Console.WriteLine("------------------------------------------------------")
Else
If Not result.OriginalMessage Is Nothing Then
Console.WriteLine("----------------- Original message part --------------")
Console.WriteLine(result.OriginalMessage.RawHeader)
Console.WriteLine(result.OriginalMessage.BodyPlainText)
Console.WriteLine("------------------------------------------------------")
End If
If Not result.DsnStructure Is Nothing Then
Console.WriteLine("---------------------- DSN part ----------------------")
Console.WriteLine(result.DsnStructure.ToString())
Console.WriteLine("------------------------------------------------------")
End If
End If
Next
End Sub
End Class
See Also