I use the following code to combine all display names and email addresse from the MailAddressCollection CC into a single string.
if ((message.CC != null) && (message.CC.Count > 0))
inbox.CC = message.CC.Aggregate((x, y) => x + ", " + y).ToString();
One of the MailAdresses OriginalAddressString has the following value
“John, Van Hellsing”
<foo@bar.com>
Cause for the problem seems to be the comma.
When the Aggregate method is called, this then throws the following exception:
The specified string is not in the form required for an e-mail address.
at Aspose.Email.MailAddress.#=zEtDcKLPeOxHa0vQG9xX5tDQ=(String #=zPUIxLQM=)
at Aspose.Email.MailAddress.#=zMPD5HAs=(String #=zx2x2eO0=)
at Aspose.Email.MailAddress.#=zk9FSvr2kY7MejzYoZA==(String #=zx2x2eO0=)
at Aspose.Email.MailAddress..ctor(String address, String displayName, Encoding displayNameEncoding)
at Aspose.Email.MailAddress.op_Implicit(String address)
at AsposeImapTest.Program.<>c.<MailsToFwkInboxes>b__1_0(MailAddress x, MailAddress y) in C:\AsposeImapTest\Program.cs:line 142
at System.Linq.Enumerable.Aggregate[TSource](IEnumerable`1 source, Func`3 func)
at AsposeImapTest.Program.MailsToFwkInboxes(MailMessage mailmessage) in C:\AsposeImapTest\Program.cs:line 142
at AsposeImapTest.Program.Main(String[] args) in C:\AsposeImapTest\Program.cs:line 52
Is there anything for me to do in order to avoid this exception?