IDENTIFY FILENAME OF EMAIL ATTACHMENT

Ankita Pandey

Total Post:183

Points:1285
Posted by  Ankita Pandey
C# 
C#
 1492  View(s)
Ratings:
Rate this:

How do I get filename of the email attachment. I am using ActiveUp.Net.Mail.

Mailbox inbox = imap.SelectMailbox("inbox");

int[] ids = inbox.Search("ALL");

ArrayList mailContainer = new ArrayList();

for (int x = 0; x < ids.Length; x++ )

{

   mailContainer.Add(inbox.Fetch.MessageObject(ids[x]));

}

foreach (Message msg in mailContainer)

{

    if (msg.Attachments.Count > 0)

    {

        msg.Attachments.StoreToFolder(@path);

    }

}

I was thinking of saving the attachment and then read the attachment...Is there a way I would directly read the attachment without saving if it in .xls format?

  1. ezra heywood

    Post:145

    Points:1019
    Re: Identify filename of Email Attachment

    Hi Ankita,


    Looks like this should work...

    foreach(var attachment in msg.Attachments)

    {

       attachment.StoreToFile(filepath + attachment.Filename);

    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!