i’m working with an old 1.1 site that uses the depreciated MailMessage class from the System.Web.Mail namespace. i updated it to use the MailMessage class from the System.Net.Mail namespace. but, the old MailMessage .To property accepted a string and the new .To property takes a MailAddressCollection, breaking my code.
the old code looked like this:
_mailMessage.To = _toName & " <" & _toEmail & ">"
you see, the To property took a name and also an email wrapped in angle brackets.
how can i do this using the new MailMessage class which takes a MailAddressCollection for it’s To property?
thanks.
You can call the MailAddress constructor inline to add recipients to your MailMessage: