'MailKit: ParseException when parsing an email string with email-address in displayname
I am currently working on a microservice that runs on DotNet6 and is using MailKit 3.1.0. I have the following code snippet:
var from = "John Doe via [email protected] <[email protected]>";
var mailBoxAddress = MailboxAddress.Parse(from);
The second line of code leads to following Exception: MimeKit.ParseException: Invalid addr-spec token at offset 0
I did some testing and found out that the following variations of the string work:
var fromAlternative1 = "John Doe via noreplycompany.com <[email protected]>"; // missing @
var fromAlternative2 = "[email protected]<[email protected]>"; // no empty space
This leads me to the question wether it could exist a configuration that enables parsing the from string, there could be a bug or this behaviour is by design?
As a workaround im parsing the displayname and email-address by myself.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
