public static void SendCrashReport(string body, string type) { try { string destfile = Path.Combine(Path.GetTempPath(), "error_report.zip"); if (File.Exists(destfile)) { File.Delete(destfile); } using (var zip = new ZipFile(destfile)) { zip.AddFile(ServiceProvider.LogFile, ""); zip.Save(destfile); } var client = new MailgunClient("digicamcontrol.mailgun.org", "key-6n75wci5cpuz74vsxfcwfkf-t8v74g82"); var message = new MailMessage("*****@*****.**", "*****@*****.**") { Subject = (type ?? "Log file"), Body = "Client Id" + (ServiceProvider.Settings.ClientId ?? "") + "\n" + body, }; message.Attachments.Add(new Attachment(destfile)); client.SendMail(message); message.Dispose(); } catch (Exception) { } }
public static void SendCrashReport(string body, string type, string email = null) { try { string destfile = Path.Combine(Path.GetTempPath(), "error_report.zip"); if (File.Exists(destfile)) { File.Delete(destfile); } using (var zip = new ZipFile(destfile)) { zip.AddFile(ServiceProvider.LogFile, ""); zip.Save(destfile); } var client = new MailgunClient("digicamcontrol.mailgun.org", "key-6n75wci5cpuz74vsxfcwfkf-t8v74g82"); var message = new MailMessage(string.IsNullOrWhiteSpace(email) ? "*****@*****.**":email, "*****@*****.**") { Subject = (type ?? "Log file"), Body = "Version :" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version + "\n" + "Client Id" + (ServiceProvider.Settings.ClientId ?? "") + "\n" + body, }; message.Attachments.Add(new Attachment(destfile)); client.SendMail(message); message.Dispose(); } catch (Exception) { } }
public async Task SendSecurityEmailAsync(string to, string toDisplayName, string subject, string body) { try { if (!EnableEmailFeature) { return; } await Task.Delay(0); var from = NoReplySender; const string fromDisplayName = "Data Crud"; var message = new MailMessage(new MailAddress(from, fromDisplayName), new MailAddress(to, toDisplayName)) { Subject = subject, Body = body, IsBodyHtml = true, }; var client = new MailgunClient(MailGunDomain, MailGunApiKey, 3); client.SendMail(message); } catch (Exception e) { Log.Information(e.ToString()); } }
public void an_authorization_exception_should_be_thrown() { var client = new MailgunClient("samples.mailgun.org", "key-aaaaaaaaaaaaaa", 3); Assert.Throws <AuthenticationException>(() => client.SendMail(MailMessageBuilder.CreateMailWithoutAttachments())); }
public void Post([FromBody] Dictionary <string, object> content) { if (ConfigurationManager.AppSettings["disableHook"] == "false") { var buildReport = JsonConvert.SerializeObject(content); int startIndex = buildReport.IndexOf("name"); int endIndex = buildReport.IndexOf(','); string appName = buildReport.Substring(startIndex + 7, endIndex - startIndex - 8); startIndex = buildReport.IndexOf("message"); string massage = buildReport.Substring(startIndex + 10); endIndex = massage.IndexOf('}'); string commitMassage = massage.Substring(0, endIndex - 1); var mailgunKeyName = "MAILGUN_API_KEY"; var mailClient = new MailgunClient("app17860.mailgun.org", ConfigurationManager.AppSettings[mailgunKeyName]); mailClient.SendMail(new System.Net.Mail.MailMessage("*****@*****.**", "*****@*****.**") { Subject = appName, Body = commitMassage }); //var emails = this.entitySet; //foreach (var email in emails) //{ // mailClient.SendMail(new System.Net.Mail.MailMessage("*****@*****.**", email.EmailName) // { // Subject = appName, // Body = commitMassage // }); //} } }
public void Send(string emailAddress, string subject, string body) { string from = ConfigurationManager.AppSettings["email_from"]; var message = new MailMessage(from, emailAddress, subject, body); message.IsBodyHtml = false; _client.SendMail(message); }
public void Post([FromBody] Dictionary <string, object> content) { var buildReport = JsonConvert.SerializeObject(content); var mailgunKeyName = "key-71yata1c1lo30of2hlltk628nh8oznu0"; var mailClient = new MailgunClient("app16919.mailgun.org", ConfigurationManager.AppSettings[mailgunKeyName]); mailClient.SendMail(new System.Net.Mail.MailMessage("*****@*****.**", "*****@*****.**") { Subject = "Build Report", Body = buildReport }); }
public void Post([FromBody] Dictionary <string, object> content) { if (ConfigurationManager.AppSettings["disableHook"] == "false") { var buildReport = JsonConvert.SerializeObject(content); var mailgunKeyName = "MAILGUN_API_KEY"; var mailClient = new MailgunClient("appcb0e83615ff044e18cb48bb38781cc5c.mailgun.org", ConfigurationManager.AppSettings[mailgunKeyName]); mailClient.SendMail(new System.Net.Mail.MailMessage("*****@*****.**", "*****@*****.**") { Subject = "Build Report", Body = buildReport }); } }
public void Post([FromBody] MailModel mail) { if (ConfigurationManager.AppSettings["MAIL_SENDER_ENABLED"] == "true") { var mailClient = new MailgunClient("app14337.mailgun.org", ConfigurationManager.AppSettings["MAILGUN_API_KEY"]); mailClient.SendMail(new System.Net.Mail.MailMessage(mail.From, mail.To) { Subject = mail.Subject, Body = mail.Body }); } else { throw new InvalidOperationException("MailSender is disabled"); } }
public void Post([FromBody] Dictionary <string, object> content) { if (ConfigurationManager.AppSettings["disableHook"] == "false") { var buildReport = JsonConvert.SerializeObject(content); var mailgunKeyName = "MAILGUN_API_KEY"; var mailClient = new MailgunClient("appfb77ce4ac30d479896173fbeb06745d4.mailgun.org", ConfigurationManager.AppSettings[mailgunKeyName]); mailClient.SendMail(new System.Net.Mail.MailMessage("*****@*****.**", "*****@*****.**") { Subject = "Build Report", Body = buildReport }); } }
public async Task SendEmailAsync(string from, string to, string toDisplayName, string subject, string body) { try { if (!EnableEmailFeature) { return; } await Task.Delay(0); if (from.IsNullEmptyOrWhiteSpace()) { from = NoReplySender; } const string fromDisplayName = "Data Crud"; if (toDisplayName.IsNullEmptyOrWhiteSpace()) { toDisplayName = to; } var message = new MailMessage(new MailAddress(from, fromDisplayName), new MailAddress(to, toDisplayName)) { Subject = subject, Body = body, IsBodyHtml = true, }; var client = new MailgunClient(MailGunDomain, MailGunApiKey, 3); client.SendMail(message); //var message = new MailMessage(NoReplySender, to, subject, body); //or //client.SendMail(new MailMessage(NoReplySender, to) //{ // Subject = subject, // Body = body //}); } catch (Exception e) { Log.Information(e.ToString()); } }
public Task SendMail(string to, string subject, string bodyHtml, string bodyText) { var client = new MailgunClient(this.settings.Domain, this.settings.ApiKey, 3); MailMessage myMessage = new MailMessage(); myMessage.To.Add(to); myMessage.From = new MailAddress("*****@*****.**", "Impera Team"); myMessage.Subject = subject; myMessage.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(bodyText, null, MediaTypeNames.Text.Plain)); myMessage.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(bodyHtml, null, MediaTypeNames.Text.Html)); client.SendMail(myMessage); return(Task.FromResult(0)); }
public static void SendEmail(string body, string subject, string email) { try { var client = new MailgunClient("digicamcontrol.mailgun.org", "key-6n75wci5cpuz74vsxfcwfkf-t8v74g82"); var message = new MailMessage("*****@*****.**", email) { Subject = subject, Body = body, }; client.SendMail(message); message.Dispose(); } catch (Exception ex) { Log.Error("Error send email", ex); } }
public void Send(FileItem item, AutoExportPluginConfig configData) { try { var filename = item.FileName; configData.IsRedy = false; configData.IsError = false; var conf = new SendEmailPluginViewModel(configData); var outfile = Path.Combine(Path.GetTempPath(), Path.GetFileName(filename)); outfile = AutoExportPluginHelper.ExecuteTransformPlugins(item, configData, outfile); var client = new MailgunClient("digicamcontrol.mailgun.org", "key-6n75wci5cpuz74vsxfcwfkf-t8v74g82", 3); var message = new MailMessage(conf.From, conf.To) { Subject = (string.IsNullOrEmpty(conf.Subject) ? "Your photo":conf.TransformTemplate(item, conf.Subject)), Body = (string.IsNullOrEmpty(conf.Message) ? "." : conf.TransformTemplate(item, conf.Message)), IsBodyHtml = true }; message.Attachments.Add(new Attachment(outfile)); client.SendMail(message); message.Dispose(); // remove unused file if (outfile != item.FileName) { PhotoUtils.WaitForFile(outfile); File.Delete(outfile); } } catch (Exception exception) { Log.Error("Error send facebook file", exception); configData.IsError = true; configData.Error = exception.Message; } configData.IsRedy = true; }
static void Main(string[] args) { MailModel mail = new MailModel(); Console.Write("From: "); mail.From = Console.ReadLine(); Console.Write("To: "); mail.To = Console.ReadLine(); Console.Write("Subject: "); mail.Subject = Console.ReadLine(); Console.Write("Body: "); mail.Body = Console.ReadLine(); var mailClient = new MailgunClient(MailSenderSettings.Default.Domain, MailSenderSettings.Default.ApiKey); mailClient.SendMail(new System.Net.Mail.MailMessage(mail.From, mail.To) { Subject = mail.Subject, Body = mail.Body }); }
public void an_authorization_exception_should_be_thrown() { var client = new MailgunClient("samples.mailgun.org", "key-aaaaaaaaaaaaaa"); Assert.Throws<AuthenticationException>(() => client.SendMail(MailMessageBuilder.CreateMailWithoutAttachments())); }