public async Task<ActionResult> SendEmailAsync(ContactForm model) { model.Subject = "Contact Form : " + model.Subject; string catalog = AppUsers.GetCatalog(); await new ContactUsEmail().SendAsync(catalog, model); Thread.Sleep(1000); return this.Json("OK"); }
public async Task<ActionResult> SendEmailAsync(ContactForm model) { model.Subject = "Contact Form : " + model.Subject; await new ContactUsEmail().SendAsync(this.Tenant, model).ConfigureAwait(false); await Task.Delay(1000).ConfigureAwait(false); return this.Json("OK"); }
private EmailQueue GetEmail(string catalog, ContactForm model) { return new EmailQueue { AddedOn = DateTime.Now, FromName = model.Name, ReplyTo = model.Email, Subject = model.Subject, Message = this.GetMessage(catalog, model), SendTo = this.GetEmails(catalog, model.ContactId) }; }
private async Task<EmailQueue> GetEmailAsync(string tenant, ContactForm model) { return new EmailQueue { AddedOn = DateTimeOffset.UtcNow, FromName = model.Name, ReplyTo = model.Email, Subject = model.Subject, Message = this.GetMessage(tenant, model), SendTo = await this.GetEmailsAsync(tenant, model.ContactId).ConfigureAwait(false) }; }
public async Task<ActionResult> SendEmailAsync(ContactForm model) { string token = this.Session[TokenKey].ToString(); if (token != model.Token) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } model.Subject = "Contact Form : " + model.Subject; string catalog = AppUsers.GetCatalog(); await new ContactUsEmail().SendAsync(catalog, model); return this.Json("OK"); }
public async Task SendAsync(string catalog, ContactForm model) { try { var email = this.GetEmail(catalog, model); var manager = new MailQueueManager(catalog, email); manager.Add(); await manager.ProcessMailQueueAsync(EmailProcessor.GetDefault()); } catch { throw new HttpException(500, "Internal Server Error"); } }
public async Task SendAsync(string tenant, ContactForm model) { var email = await this.GetEmailAsync(tenant, model).ConfigureAwait(false); var manager = new MailQueueManager(tenant, email); await manager.AddAsync().ConfigureAwait(false); var processor = EmailProcessor.GetDefault(tenant); if(processor != null) { if (string.IsNullOrWhiteSpace(email.ReplyTo)) { email.ReplyTo = processor.Config.FromEmail; } await manager.ProcessMailQueueAsync(processor).ConfigureAwait(false); } }
public async Task SendAsync(string catalog, ContactForm model) { try { var email = this.GetEmail(catalog, model); var manager = new MailQueueManager(catalog, email); manager.Add(); var processor = EmailProcessor.GetDefault(catalog); if (string.IsNullOrWhiteSpace(email.ReplyTo)) { email.ReplyTo = processor.Config.FromEmail; } await manager.ProcessMailQueueAsync(processor); } catch { throw new HttpException(500, "Internal Server Error"); } }
private string GetMessage(string catalog, ContactForm model) { string fallback = model.Email + " wrote : <br/><br/>" + this.ConvertLines(model.Message); string file = HostingEnvironment.MapPath(string.Format(CultureInfo.InvariantCulture, TemplatePath, catalog)); if (file == null || !File.Exists(file)) { return fallback; } string message = File.ReadAllText(file, Encoding.UTF8); if (string.IsNullOrWhiteSpace(message)) { return fallback; } message = message.Replace("{{Email}}", model.Email); message = message.Replace("{{Name}}", model.Name); message = message.Replace("{{Message}}", this.ConvertLines(model.Message)); return message; }