public void AddRecipient(EmailAddress recipient, EmailMessageRecipientType recipientType = EmailMessageRecipientType.To) { ValidateRecipient(recipient, recipientType); switch (recipientType) { case EmailMessageRecipientType.Cc: _ccRecipients.Add(recipient); break; case EmailMessageRecipientType.Bcc: _bccRecipients.Add(recipient); break; case EmailMessageRecipientType.To: _recipients.Add(recipient); break; case EmailMessageRecipientType.ReplyTo: _replyTo.Add(recipient); break; default: throw new ArgumentOutOfRangeException(nameof(recipientType), Validation.EmailMessage_UnknownRecipientType); } }
public void AddRecipient(string emailAddress, string displayAs = null, EmailMessageRecipientType recipientType = EmailMessageRecipientType.To) { AddRecipient(new EmailAddress(emailAddress, displayAs), recipientType); }
protected virtual void ValidateRecipient(EmailAddress recipient, EmailMessageRecipientType recipientType) { recipient.Validate(); }