// TODO: Convert these into template email public async Task InviteNewMemmberToTeamEmail(string toEmail, string emailKey, string teamName, string ownTemplate) { //create email: //Click this link to reset your password // return await emailController.SendEmail(request); string emailLink = _baseWebsiteUrl + "/#/invite-new-team?ek=" + emailKey; string contentText = "You can verify NID in real time using our automated API or using our manual portal."; string welcomeText = $"You have been invited to join the team: {teamName}."; string linkText = $"Please click here to accept the invite"; string nameText = ""; ownTemplate = ownTemplate.Replace("{{click-link}}", emailLink); ownTemplate = ownTemplate.Replace("{{click-text}}", linkText); ownTemplate = ownTemplate.Replace("{{hello-text}}", nameText); ownTemplate = ownTemplate.Replace("{{welcome-text}}", welcomeText); ownTemplate = ownTemplate.Replace("{{content-text}}", contentText); EmailForSendGrid esg = new EmailForSendGrid() { HtmlText = _template, PlainText = @"Welcome", Subject = "Invite to " + _appName, EmailTo = toEmail, DisplayNameFrom = _appName + " Support" }; await SendEmail(esg); }
public async Task SendEmail(EmailForSendGrid request) { string replyto = _emailConfig.EmailAddresses.SupportEmail; string emailFrom = _emailConfig.EmailAddresses.SupportEmail; request.EmailFrom = request.EmailFrom ?? emailFrom; var from = new EmailAddress(request.EmailFrom, request.DisplayNameFrom); var subject = request.Subject; var to = new EmailAddress(request.EmailTo); var plainTextContent = request.PlainText; var htmlContent = request.HtmlText; var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent); msg.SetReplyTo(new EmailAddress(replyto, request.DisplayNameFrom)); if (request.EmailBccs != null) { foreach (string email in request.EmailBccs) { msg.AddBcc(email); } } var response = await _sgclient.SendEmailAsync(msg); }