Skip to content

Instantly share code, notes, and snippets.

@imclint21
Created September 28, 2018 17:18
Show Gist options
  • Save imclint21/2f7a98f9c97ab7d9182a922e1c229238 to your computer and use it in GitHub Desktop.
Save imclint21/2f7a98f9c97ab7d9182a922e1c229238 to your computer and use it in GitHub Desktop.
Use SendInBlue to send confirmation mail with an activation link (use a SendInBlue template ID)
public static bool SendConfirmationEmail(string emailAddress, string activationLink)
{
var client = new RestClient("https://api.sendinblue.com/v3/smtp/email");
var sendInBlueRequest = new RestRequest(Method.POST);
sendInBlueRequest.AddHeader("api-key", "SENDINBLUE_API_KEY");
sendInBlueRequest.AddHeader("Accept", "application/json");
sendInBlueRequest.AddHeader("Content-Type", "application/json");
sendInBlueRequest.AddParameter("undefined", $"{{\"tags\":[\"Activate account for {{emailAddress}}\"],\"sender\":{{\"email\":\"[email protected]\",\"name\":\"You\"}},\"htmlContent\":\"\",\"replyTo\":{{\"email\":\"[email protected]\",\"name\":\"You\"}},\"templateId\":2,\"to\":[{{\"email\":\"{emailAddress}\",\"name\":\"{emailAddress}\"}}],\"params\":{{\"ActivationLink\":\"{activationLink}\"}}}}", ParameterType.RequestBody);
var sendInBlueResponse = client.Execute(sendInBlueRequest);
return sendInBlueResponse.IsSuccessful;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment