How you parse a collection of email addresses with mimekit?

Question: How do you parse an email with invalide characters in MailKit when using C#?

Answer: See the code below

 try
            {
                var mimeMessage = new MimeMessage();
                mimeMessage.To.Add(InternetAddress.Parse(email));
                mimeMessage.From.Add(new MailboxAddress(_emailSettings.Sender));
                mimeMessage.Bcc.Add(InternetAddress.Parse("YourEmailAddress"));

                mimeMessage.Subject = subject;

                mimeMessage.Body = new TextPart("html")
                {
                    Text = message
                };

Yes Was this page helpful? No
Yes Was this page helpful? No