Search code examples
c#asp.netemailemail-attachmentsimapx

get attached files in mail using Imapx in asp.net c#


I am using Imapx 2.0.0.9 to read the mails from gmail. It is working fine upto reading mails and get some files attached like .docx, .xls etc. But I am not getting the files attached with extensions like .txt, .rtf in attachment. Here is my code:

    var messages = client.Folders["INBOX"].Search("UNSEEN", true);
       foreach (var msg in messages)
       {

           msg.Process();
           msg.AddFlag(ImapX.ImapFlags.SEEN);
           if (msg.Attachments.Count > 0)
           {
                 for (int i = 0; i < msg.Attachments.Count; i++)
                 {
                      msg.Attachments[i].SaveFile("path to save file");
                 }
           }
       }

I am getting msg.Attachments.Count = 0 when I attach file with .txt, .rtf extensions. please help.

Thanks in advance.


Solution

  • I'm the developer of ImapX, yesterday there was a new release and the issue you mentioned here is fixed now. Please update to the latest version of the library.