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

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

Hello,

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-

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

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 mailsystem.net 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?

 

Thanks,

Developer
Jan 15, 2013 at 9:57 AM

Hi,

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 8: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 9:33 PM
Hello,

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.

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