CreateFromMailMessage generates duplicated From and To addresses #115

Closed
jacargentina opened this Issue Mar 19, 2015 · 4 comments

Projects

None yet

2 participants

@jacargentina

When using MimeKit.MimeMessage.CreateFromMailMessage static method to convert my .NET -MailMessage to a MimeMessage, i get a mail which has duplicates on the message.From and message.To collections.

Example

Original MailMessage

Result MimeMessage

@jstedfast
Owner

I have a theory. Are you doing the conversion of your MailMessage into a MimeMessage after sending it via System.Net.Mail.SmtpClient?

Looking at Microsoft's reference source for MailMessage, it looks like the MailMessage.From, To, etc are not pushed to the MailMessage.Headers until the message is sent, but I'm not 100% sure about that (I've really just given their source code a quick glance).

Since CreateFromMailMessage() clones the headers and then adds the MailMessage.From, To, Cc, etc properties to the equivalent properties on MimeMessage, it would seem that the duplicating is coming from that.

@jacargentina

Exactly, i've sent it already!
Anyway, doen't it seems like a bug? Or at least, API documentation should warn about that assumption on "the message was not sent!"

@jstedfast jstedfast added the bug label Mar 19, 2015
@jstedfast
Owner

Oh, yes, it is still a bug. I just wanted to figure out why my tests hadn't discovered the problem and to make sure I was understanding what the issue was.

I have a patch I'm about to commit...

@jstedfast jstedfast added a commit that referenced this issue Mar 19, 2015
@jstedfast Avoid duplicating the From/To/Cc/etc headers in MimeMessage.CreateFro…
…mMailMessage()

Fixes issue #115
1d18f62
@jstedfast
Owner

Okay, should be fixed now. I'll make a new MimeKit release this weekend and push new packages to NuGet when I do.

@jstedfast jstedfast closed this Mar 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment