Skip to content

Sending basic emails

Max Strålin edited this page Mar 2, 2019 · 1 revision

Sending an email is as simple as passing an IEmailMessage into an IMailjetEmailClient. Simplest way is using the default implementation, EmailMessage and MailjetEmailClient, but there's nothing stopping you from passing in any custom IEmailMessage or using any IMailjetEmailClient.

IMailjetEmailClient mailjetEmailClient = new MailjetEmailClient(opt => /*Configure public/private key*/);
IEmailMessage emailMessage = new EmailMessage("Sender Name", "Sender Email") {
     To = List<EmailEntity> { new EmailEntity("Recipient name", Recipient email") },
     HtmlBody = @"<div>Here's some HTML</div>"
}
ISendEmailResponse response = mailjetEmailClient.SendAsync(emailMessage);
Clone this wiki locally