1

When Downloading .gz files using IMAPX 2.0.0.18 I cannot extract the files as it shows them as corrupt. This happens when the file is under Message Attachments, when the same file is under Message Embedded it works fine.

I am using IMAPX with C# and ASP .NET, I am using the library quite extensively and the only problem that I am having is with downloading .gz attachments

I noticed that the bytes downloaded are not the same as the size of the file in Outlook,

  • Am I missing something?
  • Do I need to use base64 encoding, if yes can you show a sample?
  • How to use IMAPX's attachment.download and attachment.save
Mike
  • 4,041
  • 6
  • 20
  • 37
  • Are they bigger or smaller than the ones downloaded by Outlook? If they are bigger, can you try opening them in a text editor to see if they are binary files or base64 encoded? if they are base64 encoded, then you will need to decode them, otherwise it sounds like a bug in ImapX. – jstedfast Dec 14 '18 at 17:29
  • They are smaller, that's why I am confused as to why the complete file is not being downloaded. – Muhammad Ammad Saleem Dec 15 '18 at 19:20
  • It's possible that ImapX isn't parsing the response correctly. You could try using [MailKit](https://github.com/jstedfast/MailKit) instead. If that doesn't work, nothing will. – jstedfast Dec 16 '18 at 00:01
  • Ok I will try but just for info, I tried s22.imap and it has the same issue,the file is smaller as compared to the size shown in outlook and when I pass the file to 7-zip,it says that this is not a GZip file. – Muhammad Ammad Saleem Dec 16 '18 at 12:57
  • Most IMAP libraries for .NET read the response into a string and then search for `) UID ...` to figure out the end of the data which is 100% the wrong way to do it. MailKit follows the spec and reads bytes and counts the exact number of bytes that the IMAP server specifies the size is. – jstedfast Dec 16 '18 at 13:01
  • Have you had any luck? If not, let me know what problem you are facing with MailKit and I can help you. – jstedfast Dec 17 '18 at 22:16
  • Hi @jstedfast My project is in .NET 4.0 and using Visual Studio 2010. In order to install the latest MailKit from the NuGet Pacakge I need Nuget Package Manaher console 2.1.12 or higher but VS 2010 does not support this version. May be I can get MailKit.dll and reference it manually in my project? – Muhammad Ammad Saleem Dec 19 '18 at 06:02
  • MailKit 1.22.0 had .NET4.0 support, so you could try that version. – jstedfast Dec 19 '18 at 12:29
  • Hi @jstedfast I was able to download the .GZ files correctly using MailKit 1.22.0 – Muhammad Ammad Saleem Dec 21 '18 at 08:47
  • @jstedfast I also found it much much faster than IMAPX, below I am posting an issue that is currently happening – Muhammad Ammad Saleem Dec 21 '18 at 08:48
  • How can I find the current size of the MailBox using MailKit? – Muhammad Ammad Saleem Dec 21 '18 at 10:27
  • @jstedfast I have two questions for you regarding MailKit. I am using MailKit with .NET Framework 4.0 Question 1: How can I support TLS 1.2 for IMAP in MailKit? Do I need to upgrade to the latest .NET Framework? – Muhammad Ammad Saleem Apr 10 '19 at 07:54
  • @jstedfast Question 2: how can I search for email older than 90 days provided that my server does not support Within? – Muhammad Ammad Saleem Apr 10 '19 at 07:55
  • In order to get TLSv1.2 support, you need to upgrade your .NET to a version that supports it (4.6 or 4.7 I think?) and then MailKit will automatically support it. To search for messages older than 90 days, just do `folder.Search (SearchQuery.DeliveredBefore (DateTime.Now.AddDays (-90)))`. – jstedfast Apr 10 '19 at 13:50

0 Answers0