myloveCc/NETCore.MailKit

MailboxAddress parse changed

mattdef opened this issue · 1 comments

Change parsing MailboxAddress with use MailboxAddress.Parse instead of ctor parsing in Send method. (see jstedfast/MailKit#494 with report bug in MailKit library)

I change this

//add mail from
mimeMessage.From.Add(new MailboxAddress(_MailKitProvider.Options.SenderName, _MailKitProvider.Options.SenderEmail));

//add mail to 
foreach (var to in _to)
{
    mimeMessage.To.Add(new MailboxAddress("", to));
}

//add mail cc
foreach (var cc in _cc)
{
    mimeMessage.Cc.Add(new MailboxAddress("", cc));
}

//add mail bcc 
foreach (var bcc in _bcc)
{
    mimeMessage.Bcc.Add(new MailboxAddress("", bcc));
}

by this

//add mail from
mimeMessage.From.Add(MailboxAddress.Parse(string.Format("{0} <{1}>", _MailKitProvider.Options.SenderName, _MailKitProvider.Options.SenderEmail)));

//add mail to 
foreach (var to in _to)
{
    mimeMessage.To.Add(MailboxAddress.Parse(to));
}

//add mail cc
foreach (var cc in _cc)
{
    mimeMessage.Cc.Add(MailboxAddress.Parse(cc));
}

//add mail bcc 
foreach (var bcc in _bcc)
{
    mimeMessage.Bcc.Add(MailboxAddress.Parse(bcc));
}

And now it works

Thanks for your advice!