Load attachments files names without attachments in c#
First, sorry for my English.
I would like do display a list of attachments names files on mailbox. Then from this list the users will can choose which attachments they want to download on hdd - for example such as in this program: http://www.mailresender.com.ar/Read.html
I have already wrote this in Koolwired.Imap:
for (int i = 0; i < mbStructure.BodyParts.Count; i++) // i = number of parts o开发者_开发知识库f body
{
if (mbStructure.BodyParts[i].Attachment)
{
mbStructure = command.FetchBodyPart(mbStructure, i);
System.Console.WriteLine(mbStructure.BodyParts[i].Disposition); // Disposition contains file name
//System.Console.WriteLine(mbStructure.BodyParts[i].Data); // Data contains entire file
}
}
but the problem is that not only file name is loaded into memory but also data binary (entire attachment file is loaded by FetchBodyPart method) - so if files in attachment have long size (for instance 20 MB) all this 20 MB's also have to be loaded into memory, so displaying the list of file names will last very very long time.
Is there a way to load only attachments files names without files? Which library in c# could support this?
The answer to your question is ImapCommand.FetchBodyStructure, but as I'm browsing through the source I bet it will fail on some emails.
You may also take a look at Mail.dll IMAP component especially this blog post may be useful:
http://www.lesnikowski.com/blog/index.php/get-email-information-from-imap-fast/
Please note that Mail.dll is a commercial product I created.
精彩评论