toEml and save doesn't work

Topics: Help requests, Issues
Feb 28, 2014 at 7:58 AM
Hello,
I have troubles to save emails.
My code
imapClient.Folders.Inbox.Messages.Download("ALL", Enums.MessageFetchMode.Full, 10)
                For Each mx In imapClient.Folders.Inbox.Messages
                    Console.WriteLine(mx.InternalDate & "-" & mx.UId)
                    Dim eml As String = mx.ToEml()
                    'mx.SaveTo(".\", mx.UId.ToString & ".eml")
                Next
Calling ToEml throws NullReferenceException

v ImapX.MessageBuilder.ToEml(Message message) v c:\Users\Pavel\Projects\ImapX\ImapX\MessageBuilder.cs:řádek 107
v ImapX.Message.ToEml() v c:\Users\Pavel\Projects\ImapX\ImapX\Message.cs:řádek 619
v imapArchive.mmswImap.Main() v F:_VS2013\imapArchive\mmswImap.vb:řádek 13
v System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
v System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
v Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
v System.Threading.ThreadHelper.ThreadStart_Context(Object state)
v System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
v System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
v System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
v System.Threading.ThreadHelper.ThreadStart()

Would you be so kind to help me?
Thank you
Miroslav
Coordinator
Feb 28, 2014 at 11:01 AM
Hi Miroslav,

thank you for the stacktrace! I will check the details in the code and provide a fix.

Greets,

Pavel
Mar 3, 2014 at 8:06 PM
Hi,
I have the same error when using. SaveTo ()
   f.Messages.Download("ALL", ImapX.Enums.MessageFetchMode.Full)
            For Each m As ImapX.Message In f.Messages
                m.Download(ImapX.Enums.MessageFetchMode.Full, True)
                m.SaveTo(Me.txtFolder.Text, m.GMailMessageId & ".eml")
                .....
Image

Thank you
Coordinator
Mar 4, 2014 at 11:21 AM
Thank you for the reports!

As a temporary fix you can use the Message.DownloadRawMessage method, for details see my answer in this thread.

Best regards,

Pavel