ResultDsnStructure Property
DsnAttachment object representing RFC 1894 DSN attachment to this DSN message.

Namespace: MailBee.BounceMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
Syntax
public DsnAttachment DsnStructure { get; }

Property Value

Type: DsnAttachment
A 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.

// To use the code below, import these namespaces at the top of your code.
using System;
using System.IO;
using MailBee.Mime;
using MailBee.BounceMail;

class Sample
{
    static void Main(string[] args)
    {
        // Load the templates database from file(s).
        DeliveryStatusParser parser = new DeliveryStatusParser (@"C:\Temp\BounceDatabase\all.xml", true);
        string[] files = Directory.GetFiles(@"C:\Temp\IncomingMail", "*.eml");
        MailMessage msg = new MailMessage();

        // Iterate through all messages in the folder.
        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
            {
                // Get original e-mail message part.
                if (result.OriginalMessage != null)
                {
                    Console.WriteLine("----------------- Original message part --------------");
                    Console.WriteLine(result.OriginalMessage.RawHeader);
                    Console.WriteLine(result.OriginalMessage.BodyPlainText);
                    Console.WriteLine("------------------------------------------------------");
                }

                // Get DSN attachment part.
                if (result.DsnStructure != null)
                {
                    Console.WriteLine("---------------------- DSN part ----------------------");
                    Console.WriteLine(result.DsnStructure.ToString());
                    Console.WriteLine("------------------------------------------------------");
                }
            }
        }
    }
}
See Also