Archived Forum Post

Index of archived forum posts

Question:

Get Multipart

May 23 '16 at 04:31

Hi,

I can't seem to find a method that can get multipart properties from an email ("To & Return-Path")

namespace ConsoleApplication1 { class Program {

    static void Main(string[] args) {

        string filepath = Path.GetDirectoryName("/Users/Documents/feedback/feedback.yahoo/4E/");
        DirectoryInfo d = new DirectoryInfo(filepath);

        foreach (var file in d.GetFiles("*.eml"))
        {

            var o = file.FullName;
            Console.WriteLine("FILE: " + o);

            // Place file path as variable in loop

            Chilkat.Email email = new Chilkat.Email();

            //  First, load an email from a file.
            //  Note: an email object may be loaded from a file, or
            //  downloaded directly from a POP3 or IMAP server...
            bool success;
            success = email.LoadEml(o);
            if (success != true)
            {
                Console.WriteLine(email.LastErrorText);
                return;
            }

            //  How many header fields?
            int n;
            n = email.NumHeaderFields;
            if (n > 0)
            {

                //  Display the name and value of each header:
                int i;
                string subscriber;
                string client;
                string cleanclient;
                string alternative;
                bool isMultipart;
                string toAdd;

                for (i = 0; i <= 1 - 1; i++)
                {
                    isMultipart = email.IsMultipartReport();
                    client = email.GetDeliveryStatusInfo("Original-Mail-From"); //YAHOO
                    subscriber = email.GetDeliveryStatusInfo("Original-Rcpt-To");
                    toAdd = email.GetToAddr(i);
                    alternative = email.GetReport(i);

                    if (client == null)
                    {
                        isMultipart = email.IsMultipartReport();
                        client = email.GetAltHeaderField(i, "Subject");        //AOL
                        subscriber = email.EmailDateStr;
                        Console.WriteLine("Multipart?: " + isMultipart);
                        Console.WriteLine("Subscriber: " + subscriber);
                        Console.WriteLine("-----------------------------------");

                    }
                    else
                    {

                        //remove angle brackets
                        cleanclient = Regex.Replace(client, @"[<$>]", "");

                        //remove rest of email address after @
                        int x = cleanclient.IndexOf("@");
                        if (x > 0)
                            cleanclient = cleanclient.Substring(0, x);

                        Console.WriteLine("Multipart?: " + isMultipart);
                        Console.WriteLine("Client: " + cleanclient);
                        Console.WriteLine("Subscriber: " + subscriber);
                        Console.WriteLine("-----------------------------------");
                    }
                }
            }
        }
    }

        }

    }