DsnAttachmentItems Property
Gets the list of all fields in the DSN attachment.

Namespace: MailBee.BounceMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax
public StringDictionary Items { get; }

Property Value

Type: StringDictionary
The key-value string collection of all the fields in the DSN attachment.
Remarks
This collection is alternative to other properties of DsnAttachment class. Other properties (like ArrivalDate) return the corresponding value in parsed form. Items property provides access to all the fields as they are specified in the DSN source. It can also be used to extract those values which are not available through other properties (for instance, vendor-specific properties which are not defined by RFC 1894).
Examples
This code sample shows how to operate with parsed DSN data.
// 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 DSN templates database from file.
        DeliveryStatusParser parser = new DeliveryStatusParser(@"C:\Temp\BounceDatabase\all.xml", true);

        string[] files = Directory.GetFiles(@"C:\Temp\IncomingMail", "*.eml");
        MailMessage msg = new MailMessage();

        // Process all .EML files in the folder.
        foreach (string file in files)
        {
            msg.LoadMessage(file);
            Result result = parser.Process(msg);

            Console.WriteLine("\r\nProcessed e-mail: " + file);

            if (result == null || result.DsnStructure == null)
            {
                Console.WriteLine("------------------------------------------------------");
                Console.WriteLine("This message doesn't have DSN message part.");
                Console.WriteLine("------------------------------------------------------");
            }
            else
            {
                Console.WriteLine("------------------ DSN part as text ------------------");
                Console.WriteLine(result.DsnStructure.ToString());
                Console.WriteLine("------------- DSN header as StringDictionary ---------");
                foreach (string key in result.DsnStructure.Items.Keys)
                {
                    Console.WriteLine("DSN item: {0} = {1}", key, result.DsnStructure.Items[key]);
                }
                Console.WriteLine("------------------------------------------------------");

                foreach (RecipientStatus res in result.Recipients)
                {
                    if (res.DsnInfo != null)
                    {
                        Console.WriteLine("DSN subpart for: {0} e-mail", res.EmailAddress);
                        Console.WriteLine("---------------- DSN subpart as text -----------------");
                        Console.WriteLine(res.DsnInfo.ToString());
                        Console.WriteLine("------------- DSN header as StringDictionary ---------");
                        foreach (string key in res.DsnInfo.Items.Keys)
                        {
                            Console.WriteLine("DSN subpart item: {0} = {1}", key, res.DsnInfo.Items[key]);
                        }
                        Console.WriteLine("------------------------------------------------------");
                    }
                }
            }
        }
    }
}
See Also