/// <summary> /// Send a marketing welcome email to a user who has signed up to recieve marketing emails. /// </summary> /// <param name="mUser">Marketing user information</param> /// <returns>None.</returns> public async Task SendMarketWelcome(MarketingUser mUser) { // Create information for a new marketing email var data = new MarketingWelcomeEmail { User = mUser.Name, Email = mUser.Email, UnsubscribeLink = string.Format("https://patrons.at/email/unsubscribe/{0}", await _database.CreateMarketingUserUnsubscribeLink(mUser)) }; // Convert data to a JSON string. string jsonData = JsonSerializer.Serialize <MarketingWelcomeEmail>(data); // Required template information: // * name: user name // * email: email address // * unsubscribe_link: unsubscribe link var emailRequest = new SendTemplatedEmailRequest() { Source = "*****@*****.**", Destination = new Destination { ToAddresses = new List <string> { mUser.Email } }, Template = "marketing-welcome", TemplateData = jsonData, }; // Send the email. await _emailClient.SendTemplatedEmailAsync(emailRequest); }