Quantcast
Channel: ImapX 2
Viewing all articles
Browse latest Browse all 1952

New Post: Attachment not downloaded correctly (Version 2.0.0.13)

$
0
0
I am writing a program in C# to access the UNREAD emails from Gmail using ImapX (Version 2.0.0.13). I wish to download specifically the powerpoint (.ppt or .pptx) files in the attachment. I have made the download of attachment work. However, the downloads are not saved correctly on the disk. For example, if an attachment is of size 3.5 MB only 2.4 MB of it is saved. Am I missing a step here?

Any help would be greatly appreciated. Thanks in advance.

Here is my code:

using(ImapClient client = new ImapClient(host, port, true, true))
{
if (client.Login(username, password))
{
    FolderCollection folders = client.Folders;
    Message[] messages = client.Folders["INBOX"].Search("UNSEEN", MessageFetchMode.Attachments, 100);

    for (int i = 0; i < messages.Length; i++)
    {
        if (messages[i].Attachments.Length > 0)
        {
            Attachment[] atts = messages[i].Attachments;
            for (int j = 0; j < atts.Length; j++)
            {
                if (atts[j].FileName.Contains("ppt") || atts[j].FileName.Contains("pptx"))
                {
                    atts[j].Download();
                    atts[j].Save(SAVE_LOCATION, atts[j].FileName);
                }
            }
        }
    }
}
}

Viewing all articles
Browse latest Browse all 1952

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>