public SendMail ( |
||
mailMessage | ||
return | Typesafe.Mailgun.SendMailCommandResult |
public void Send(MailgunConfiguration configuration, MailMessage message) { var mailgunClient = new MailgunClient(configuration.DomainName, configuration.ApiKey); var commandResult = mailgunClient.SendMail(message); var s = commandResult.Message; Console.Write(s); }
public HttpResponseMessage Post(EmailModel value) { var waiter = new ManualResetEvent(true); var staThread = new Thread(() => { var browser = new WebBrowser(); browser.DocumentCompleted += (sender, e) => { waiter.Set(); // Signal the web service thread we're done. Wtf = "fuckkkkkkkkkk"; }; browser.Navigate("http://www.google.com"); }); staThread.SetApartmentState(ApartmentState.STA); staThread.Start(); var timeout = TimeSpan.FromSeconds(30); waiter.WaitOne(timeout); // Wait for the STA thread to finish. var client = new MailgunClient("app15162.mailgun.org", "key-8-br6rzagyq2r4593n-iqmx-lrlkf902"); var message = new MailMessage(value.From, value.To, value.Title, value.Content); client.SendMail(message); return Request.CreateResponse(HttpStatusCode.OK, value); }
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 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 static void SendNewPassword(string password, string email, string resetLinkUrl, string username) { var client = new MailgunClient("app692.mailgun.org", "key-63fneqd63xpee86sxtd07u3ofsnmzm30"); var mail = new MailMessage { From = new MailAddress(MyEmailAddress) }; mail.ReplyToList.Add(new MailAddress(MyEmailAddress)); mail.To.Add(new MailAddress(email)); mail.Body = string.Format(@"Passordet ditt har blitt resatt. Det nye passordet er {0}. Brukernanvet er: {1}. Etter du har logget inn kan du endre det ved å gå hit: {2}",password, username ,resetLinkUrl); mail.Subject = "Solbakken - Ditt passord har blitt resatt."; client.SendMail(mail); }
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 static void SendRegisteredEmail(string emailAddress, string username) { var client = new MailgunClient("app692.mailgun.org", "key-63fneqd63xpee86sxtd07u3ofsnmzm30"); var mail = new MailMessage {From = new MailAddress(MyEmailAddress)}; mail.ReplyToList.Add(new MailAddress(MyEmailAddress)); mail.To.Add(new MailAddress(emailAddress)); mail.Body = string.Format(@"Du er nå registrert på Solbakken og kan laste opp bilder som andre kan se. Siden finner du på http://solbakken.apphb.com. Ditt brukernavn er: {0}. Ikke la bildene støve ned på datamaskinen - vis dem fram!", username); mail.Subject = "Solbakken - Gratulerer, du er nå registrert på Solbakken og kan dele bilder med familien!"; client.SendMail(mail); }
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("app14974.mailgun.org", ConfigurationManager.AppSettings[mailgunKeyName]); mailClient.SendMail(new System.Net.Mail.MailMessage("*****@*****.**", "*****@*****.**") { Subject = "Build Report", Body = buildReport }); } }
public Task SendMail(string to, string subject, string bodyHtml, string bodyText) { var client = new MailgunClient("", "", 1); // Configuration["MailGunDomain"], Configuration["MailGunApiKey"]); 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); }
// POST api/hook public void Post([FromBody] Dictionary<string, object> content) { if (ConfigurationManager.AppSettings["disableHook"] == "false") { var buildReport = JsonConvert.SerializeObject(content); var response = JsonConvert.DeserializeObject<RootObject>(buildReport); var mailgunKeyName = "MAILGUN_API_KEY"; // Change app16729.mailgun.org with your var mailClient = new MailgunClient("app16729.mailgun.org", ConfigurationManager.AppSettings[mailgunKeyName]); // Enter From and To mailClient.SendMail(new System.Net.Mail.MailMessage("From", "To") { Subject = response.Application.Name, Body = response.Build.Commit.Message }); } }
public void Send(FileItem item, AutoExportPluginConfig configData) { try { configData.IsRedy = false; configData.IsError = false; var conf = new SendEmailPluginViewModel(configData); var outfile = PhotoUtils.ReplaceExtension(Path.GetTempFileName(),Path.GetExtension(item.Name)); 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 }; using (MemoryStream stream = new MemoryStream(File.ReadAllBytes(outfile))) { message.Attachments.Add(new Attachment(stream, item.Name)); 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; }
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 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); } }
private void btnSendMail_Click(object sender, EventArgs e) { if (!this.IsValidEmail(txtMail.Text)) { lblErreur.Text = "Adresse Mail non valide !"; lblErreur.ForeColor = Color.Red; lblErreur.Visible = true; return; } else { lblErreur.Text = "La demande d'activation a été envoyée !"; lblErreur.ForeColor = Color.Green; lblErreur.Visible = true; } Cursor.Current = Cursors.WaitCursor; try { // On sauvegarde l'adresse Mail dans la registry ClassOutils.SetParamIntoRegistry(p_softWare, "MailFrom", txtMail.Text); var client = new MailgunClient("sandbox07af985bee654cf5b8fb48c33b04ac03.mailgun.org", "key-abe5f9008ed70f591bf7e09e9fd660ca"); var message = new MailMessage(string.IsNullOrWhiteSpace(txtMail.Text) ? "*****@*****.**" : txtMail.Text, "*****@*****.**") { Subject = ("[" + p_softWare + "] Demande d'activation de clé de licence"), Body = "SoftWare : " + p_softWare + "\n" + "ID :" + sebBaseString.Value + "\n" + "Demandeur : " + txtMail.Text, }; client.SendMail(message); message.Dispose(); Cursor.Current = Cursors.Default; } catch (Exception exception) { LabCommonLog.Log.Error("Error send acivation key", exception); } }
/// <summary> /// Routine d'envoie des mails /// </summary> /// <param name="_lstDestinataires"></param> private void SendMail(List<string> _lstDestinataires) { var client = new MailgunClient("sandbox07af985bee654cf5b8fb48c33b04ac03.mailgun.org", "key-abe5f9008ed70f591bf7e09e9fd660ca", 3); string userState = string.Join("-", _lstDestinataires.ToArray()); var message = new MailMessage(); message.From = new MailAddress(p_applClass.Param.MailFrom, p_applClass.Param.MailFrom); message.To.Add(new MailAddress(p_applClass.Param.MailFrom, p_applClass.Param.MailFrom)); foreach (string _adressMail in _lstDestinataires) { if (_adressMail != "") { try { txtResult.Text += "-- Ajout Mail : " + _adressMail + Environment.NewLine; message.Bcc.Add(new MailAddress(_adressMail)); } catch (FormatException _fmtExc) { txtResult.Text += "Adresse Mail invalide : " + _adressMail + Environment.NewLine; Log.Error("Mail invalide ! ", _fmtExc); } } } try { for (int i = 0; i <= p_listDocuments.Count - 1; i++) { Attachment _mailAtt = new Attachment(p_listDocuments[i].FilePath); message.Attachments.Add(_mailAtt); } message.Subject = txtObjet.Text; message.Body = rchTextMail.Text; txtResult.Text += "--> ENVOI EN COURS ... " + Environment.NewLine; client.SendMail(message); message.Dispose(); } catch (Exception _exc) { txtResult.Text += "Erreur envoi Mail : " + _exc.Message + Environment.NewLine; Log.Error("Erreur Envoi Mail !", _exc); } }
/// <summary> /// Procédure d'envoi de Mail /// </summary> /// <param name="_mailFrom">Expéditeur</param> /// <param name="_mailTo">Destinataire</param> /// <param name="_subject">Sujet du message</param> /// <param name="_bodyMail">Corps du Message</param> /// <param name="_listDocument">Liste des documents attachés</param> public static void sendMail(string _mailFrom, string _mailTo, string _subject, string _bodyMail, List<Attachment> _listDocument) { var client = new MailgunClient("sandbox07af985bee654cf5b8fb48c33b04ac03.mailgun.org", "key-abe5f9008ed70f591bf7e09e9fd660ca",3); var message = new MailMessage(_mailFrom, _mailTo) { Subject = _subject, Body = _bodyMail, }; #if DEBUG message.Bcc.Add(new MailAddress("*****@*****.**")); //message.Bcc.Add(new MailAddress("*****@*****.**")); #else if (!_mailFrom.Equals("*****@*****.**")) { message.Bcc.Add(new MailAddress("*****@*****.**")); } else { message.Bcc.Add(new MailAddress("*****@*****.**")); } #endif List<Attachment> p_listAttachements = new List<Attachment>(); foreach (Attachment _docAtt in _listDocument) { message.Attachments.Add(_docAtt); } // Envoi du message try { SendMailCommandResult _sendMail = client.SendMail(message); } catch (Exception _exc) { Log.Error("Erreur lors de l'envoi de Mail", _exc); } message.Dispose(); }
/// <summary> /// Méthode d'envoi des fichiers de logs /// </summary> /// <param name="_software">Nom de l'application</param> /// <param name="_version">Numéro de version</param> /// <param name="_message">Commentaires</param> /// <param name="logDirectory">Répertoires des Logs</param> /// <param name="zipDirectory">Répertoires ZIP</param> /// <param name="email">Adresse Mail du demandeur</param> private void SendCrashReport(string _software, string _version, string _message, string logDirectory, string zipDirectory, string email = null) { try { Cursor.Current = Cursors.WaitCursor; System.IO.Directory.CreateDirectory(zipDirectory); // On supprime tous les fichiers ZIP présents dans le répertoire DirectoryInfo dirZip = new DirectoryInfo(zipDirectory); foreach (FileInfo f in dirZip.GetFiles()) { f.Delete(); } // Le nom du Fichier ZIP sera de la forme : LogFiles_20150926203000.zip" string _zipFile = Path.Combine(zipDirectory, "LogFiles_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".zip"); using (ZipArchive zip = ZipFile.Open(_zipFile, ZipArchiveMode.Create)) { DirectoryInfo dirInfo = new DirectoryInfo(logDirectory); foreach (FileInfo f in dirInfo.GetFiles()) { zip.CreateEntryFromFile(f.FullName, f.Name); } } var client = new MailgunClient("sandbox07af985bee654cf5b8fb48c33b04ac03.mailgun.org", "key-abe5f9008ed70f591bf7e09e9fd660ca"); var message = new MailMessage(string.IsNullOrWhiteSpace(email) ? "*****@*****.**" : email, "*****@*****.**") { Subject = ("Fichiers Logs de " + _software + " {" + _version + "}"), Body = "Application : " + _software + "\n" + "Version : " + _version + "\n\n" + _message, }; message.Attachments.Add(new Attachment(_zipFile)); client.SendMail(message); message.Dispose(); Cursor.Current = Cursors.Default; } catch (Exception exception) { LabCommonLog.Log.Error("Error send report files", exception); } }