andrewdavey / postal

Email sending for asp.net mvc using the view engine system to render emails.
http://aboutcode.net/postal
MIT License
536 stars 169 forks source link

The parameter 'addresses' cannot be an empty string. #176

Closed bjohndev closed 5 years ago

bjohndev commented 5 years ago

I'm having an issue where I get the error "The parameter 'addresses' cannot be an empty string." when I call EmailService.CreateMailMessage. I'm familiar with that error when dealing directly with MailMessage objects. I have confirmed all the properties are set for To, From and CC. The BCC is not set.

could the BCC being blank be the problem? Is there anywhere else I should be looking to set email addresses?

bjohndev commented 5 years ago

I figured out the cause of my issue. I had a custom class that inherited from Postal.Email, it declared a property Bcc, and because it was declared in my custom class, the "CreateMailMessage" failed because it doesn't check to see if a property is string.IsNullOrEmpty prior to trying to assign or map the Bcc property to the MailMessage object for .net. Adding a value for Bcc or removing the Bcc from my custom Email class resolved my issue.