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?
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);
}
}
}
}
}
}
The problem was solved after I downloaded the updated source code from the ImapX site. It works perfectly now with the above source code.