This project is read-only.

Encoding issue? strange issue..what would be a solution?

Jan 14, 2013 at 4:30 PM
Edited Jan 14, 2013 at 4:37 PM


Here is simple flow.

SQL server sends an email using msdb.dbo.sp_send_dbmail to my gmail account.

This MailSystem.NET read that email by IMAP4 from the gmail account.

It seems working fine, but the issue is that..

It always throws exception when initially reading(always very first time) that email from this line..

Message newMessage = inBox.Fetch.MessageObject(n);

--this is exception stack trace-

   at ActiveUp.Net.Mail.Parser.ParseMessage(Byte[] data)
   at ActiveUp.Net.Mail.Fetch.MessageObject(Int32 messageOrdinal)

From second time inBox.Fetch.MessageObject,, I don't see any error.

Only thing I can guess would be, basically, sql server uses base64 encoding internally when sending out email...It may cause this issue???....Then strange thing is I don't see this exception from second time. Maybe gmail decoded somehow initially very frist-time when reading, so didn't cause any issue when parsing from second-time?

1. I can't find any way to change encoding from sql server mail feature side.

2. I can't rely on this "working" from second-time.

What would be best way to handle this issue?



Jan 15, 2013 at 10:57 AM


could you please post some more information about the exception.

What is the exception message?


I don't think that it is a encoding problem.

Would it be possible to attach such a mail as eml?

Sep 24, 2013 at 9:30 PM
Did you ever find a solution to this? I too was seeing an issue in the Parser.ParseMessage (public static Message ParseMessage(byte[] data)) method; Object reference not set errors. Everything looked good. I added some Logger.AddEntry messages to see if the data was null, and the data.Length and it magically went through.

Sep 24, 2013 at 10:33 PM

It was quite long time ago, but I kinda remember this issue..

As far as I remember, there was a bug in the source code (ActiveUp.Net.Mail,Parser.DecodePartBody)..
Based on my source review, there was the offset bug...
part.TextContent.LastIndexOf("=") + 1 should change to part.TextContent.LastIndexOf("=")

Then you should be able to run without having this issue.

Sep 25, 2013 at 12:41 PM
That probably was it - Thank you so much for your quick response!