/// <summary> /// Save the email task /// </summary> /// <param name="email">The email information value.</param> /// <param name="status">The eamil status sendding or not.</param> private void SaveEmailTask(EmailTask email, string status) { email.Status = status; email.CreateDate = DateTime.Now; _unitOfWork.GetRepository <EmailTask>().Add(email); _unitOfWork.Complete(); }
private void EmailMessageResult_Load(object sender, EventArgs e) { mm = EmailTask.GetAllMailMessage(ec).ToArray(); foreach (MailMessage mm1 in mm) { mm1.HeadersEncoding = Encoding.UTF8; listBox1.Items.Add(mm1.From.DisplayName + ":" + mm1.Subject); } }
private async Task <IHttpActionResult> Handle(EmailTask task) { await Emails.SendMail( task.Recipient, Encoding.UTF8.GetString(Convert.FromBase64String(task.Subject)), Encoding.UTF8.GetString(Convert.FromBase64String(task.Content))); return(Ok()); }
public void SendEmailWithPlainText() { var input = _input; input.Subject = "Email test - PlainText"; var result = EmailTask.SendEmail(input, null, _options, new System.Threading.CancellationToken()); Assert.IsTrue(result.EmailSent); }
static void Main(string[] args) { EmailTask _emailTask = new EmailTask(); ThreadStartCommand _emailTaskCommand = new ThreadStartCommand(_emailTask, "Send"); Thread _t1 = new Thread(_emailTaskCommand); _t1.Start(); SMSTask _smsTask = new SMSTask(); ThreadStartCommand _smsTaskCommand = new ThreadStartCommand(_smsTask,"Send"); Thread _t2 = new Thread(_smsTaskCommand); _t2.Start(); }
public bool SendEmail3() { EmailTask task = new EmailTask(); task.Subject = "Test"; task.Body = "Body"; task.To.Add(new Users.Dto.UserDto() { FullName = "Eric Xu", EmailAddress = "*****@*****.**" }); backgroundJobManager.Enqueue <EmailSenderJob, EmailTask>(task); return(true); }
public void TrySendingEmailWithNoFileAttachmentFoundException() { var input = _input; input.Subject = "Email test"; var attachment = new Attachment { FilePath = Path.Combine(_localAttachmentFolder, TEST_FILE_NOT_EXISTING), SendIfNoAttachmentsFound = false, ThrowExceptionIfAttachmentNotFound = true }; var Attachments = new Attachment[] { attachment }; Assert.Throws <FileNotFoundException>(() => EmailTask.SendEmail(input, Attachments, _options, new System.Threading.CancellationToken())); }
public void SendEmailWithFileAttachment() { var input = _input; input.Subject = "Email test - FileAttachment"; var attachment = new Attachment { FilePath = _filepath, SendIfNoAttachmentsFound = false, ThrowExceptionIfAttachmentNotFound = true }; var Attachments = new Attachment[] { attachment }; var result = EmailTask.SendEmail(input, Attachments, _options, new System.Threading.CancellationToken()); Assert.IsTrue(result.EmailSent); }
public void SendEmailWithStringAttachment() { var input = _input; input.Subject = "Email test - AttachmentFromString"; var fileAttachment = new AttachmentFromString() { FileContent = "teststring ä ö", FileName = "testfilefromstring.txt" }; var attachment = new Attachment() { AttachmentType = AttachmentType.AttachmentFromString, stringAttachment = fileAttachment }; var Attachments = new Attachment[] { attachment }; var result = EmailTask.SendEmail(input, Attachments, _options, new System.Threading.CancellationToken()); Assert.IsTrue(result.EmailSent); }
public void TrySendingEmailWithNoFileAttachmentFound() { var input = _input; input.Subject = "Email test"; var attachment = new Attachment { FilePath = Path.Combine(_localAttachmentFolder, TEST_FILE_NOT_EXISTING), SendIfNoAttachmentsFound = false, ThrowExceptionIfAttachmentNotFound = false }; var Attachments = new Attachment[] { attachment }; var result = EmailTask.SendEmail(input, Attachments, _options, new CancellationToken()); Assert.IsFalse(result.EmailSent); }
public async Task ExecuteTask_WhenToAndCcAndBccAreNotSet_ShouldFails() { // Arrange var smtpService = CreateSmtpService(new SmtpSettings()); var task = new EmailTask( smtpService, new SimpleWorkflowExpressionEvaluator(), Mock.Of <IStringLocalizer <EmailTask> >(), HtmlEncoder.Default) { Subject = new WorkflowExpression <string>("Test"), Body = new WorkflowExpression <string>("Test message!!") }; var executionContext = new WorkflowExecutionContext( new WorkflowType(), new Workflow(), EmptyDictionary, EmptyDictionary, EmptyDictionary, new List <ExecutedActivity>(),
public ActionResult Create(FlightFareInformationModel model) { try { string origin = model.DepartCity; string destination = model.ArriveCity; string[] emails = model.EmailReceivers.SplitNewLine(); DateTime taskStartDate = model.TaskBeginDate.Value; DateTime[] departureDate = model.DepartureDate.SplitNewLine().Select(Convert.ToDateTime).ToArray(); int hour = Convert.ToInt32(StringHelper.GetHour(model.Duration)); int minute = Convert.ToInt32(StringHelper.GetMinute(model.Duration)); bool isAm = model.rdbAmPm == AmPm.AM; EmailTask task = new EmailTask(origin, destination, departureDate.Distinct().ToArray()); task.EmailReceiver = emails.Distinct(StringComparer.CurrentCultureIgnoreCase).ToArray(); task.Time = new TimeSpan(0, isAm ? hour : hour + 12, minute, 0); task.TaskStartDate = taskStartDate; using (var lib = new TaskLibrary()) { lib.AddTask(task); TempData["SuccessMessage"] = "Task has been successfully created."; return(RedirectToAction("Create")); } } catch (Exception ex) { model.DepartCityList = new SelectList(ser.GetCityList(), "CityID", "CityCode"); model.ArriveCityList = new SelectList(ser.GetCityList(), "CityID", "CityCode"); //TempData["ActionResponse"] = "Unable to create a task."; TempData["ActionResponse"] = ex.Message; return(View(model)); } }