protected override async Task <TypedActionHandlerResult <string> > Execute(Dictionary <string, object> data, RecipeAction recipeAction, SendEmailData actionData) { var externalService = await recipeAction.GetExternalService(); var smtpService = new SmtpService(externalService); var message = new MimeMessage(new List <InternetAddress>() { InternetAddress.Parse(InterpolateString(actionData.From, data)) }, new List <InternetAddress>() { InternetAddress.Parse(InterpolateString(actionData.To, data)) }, InterpolateString(actionData.Subject, data), new TextPart(TextFormat.Plain) { Text = InterpolateString(actionData.Body, data) }); await smtpService.SendEmail(message); return(new TypedActionHandlerResult <string>() { Executed = true, Result = $"Sent email to {message.To} from {message.From} with subject {message.Subject} and body {message.Body}", TypedData = message.ToString() }); }
protected override async Task <ActionHandlerResult> Execute(object triggerData, RecipeAction recipeAction, SendEmailData actionData) { var smtpService = new SmtpService(recipeAction.ExternalService); var message = new MimeMessage(new List <InternetAddress>() { InternetAddress.Parse(InterpolateString(actionData.From, triggerData)) }, new List <InternetAddress>() { InternetAddress.Parse(InterpolateString(actionData.To, triggerData)) }, InterpolateString(actionData.Subject, triggerData), new TextPart(TextFormat.Plain) { Text = InterpolateString(actionData.Body, triggerData) }); await smtpService.SendEmail(message); return(new ActionHandlerResult() { Result = $"Sent email to {message.To} from {message.From} with subject {message.Subject} and body {message.Body}" }); }
private async Task OnPublish() { IClipboardService cService = new ClipboardService(); var htmlBody = await cService.GetText(); if (!string.IsNullOrEmpty(htmlBody)) { var smtpService = new SmtpService(); var prepareTitle = await PrepareTitleForMyBlogPostAsync(); smtpService.SendEmail(prepareTitle, htmlBody); } }
public void SendEmail_ValidEmail_Ok() { SmtpService smtpService = new SmtpService(); const string filePath = @"C:\Users\phantomer\Documents\Visual Studio 2013\Projects\ImageMaker\Test\5_ozer.png"; byte[] fileContent = new byte[0]; if (File.Exists(filePath)) { fileContent = File.ReadAllBytes(filePath); } bool result = smtpService.SendEmail(fileContent); Assert.IsTrue(result); }
public override WorkflowExecutionStatus Execute( Record record, RecordEventArgs e) { try { var smtpService = new SmtpService(); var template = $"~/Views/Partials/{TemplateName}"; var emailBody = File.ReadAllText(System.Web.HttpContext.Current.Server.MapPath(template)) .Replace("[[SUBJECT]]", Subject) .Replace("[[HEADING]]", Heading) .Replace("[[BODY]]", Message); smtpService.SendEmail(emailBody, ToEmail, FromEmail, FromName, Subject, ReplyTo, Bcc, Cc); return(WorkflowExecutionStatus.Completed); } catch (Exception ex) { LogHelper.Error <CustomEmailWorkflow>(ex.Message, ex); return(WorkflowExecutionStatus.Failed); } }