Attachment not downloaded correctly (Version 2.0.0.13)

Topics: Issues
Dec 4, 2013 at 12:27 PM
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);
                }
            }
        }
    }
}
}
Coordinator
Dec 4, 2013 at 1:14 PM
Hi vermahimanshu7,

your code is correct, however there's a bug in the current version of ImapX which makes some attachments corrupted. I'm working on fixing this as fast as possible. An updated version might be available already tonight.

Best regards,

Pavel
Dec 4, 2013 at 2:41 PM
Hi Pavel,

Thanks for your reply :)

Best,
Himanshu
Coordinator
Dec 6, 2013 at 8:17 PM
Hi Himanshu,

you can try the latest code in the repository, the attachments should not be corrupted anymore.

Greets,

Pavel
Dec 11, 2013 at 8:54 AM
Hi Pavel,
I have downloaded the latest code and will try it now. Thank you very much for your help with the issue :)

Best regards,
Himanshu
Coordinator
Dec 11, 2013 at 2:24 PM
Hi Himanshu,

thank you really much! Waiting for the test results!

Kind regards,

Pavel
Dec 12, 2013 at 3:39 PM
Hi Pavel,

The code works perfectly for me, the attachments are downloaded and the download performance is significantly improved :)

Thank you very much for your great help!

Cheers,
Himanshu
Coordinator
Dec 12, 2013 at 8:23 PM
Hi Himanshu,

great to hear that! I will do another few bugfixes this weekend and release the new version to the public. Thank you for taking time to test the code!

Greets,

Pavel