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
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.
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.

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)
            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("This message doesn't have DSN & original message part.");
                // Get original e-mail message part.
                if (result.OriginalMessage != null)
                    Console.WriteLine("----------------- Original message part --------------");

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