private void SendMailToVendors(QuoteInterested model) { try { string errMsg = String.Empty; NuvemMailMessage msg = new NuvemMailMessage(); List <string> Emails = new List <string>(); string subject = "Nuvem B2B"; if (!string.IsNullOrEmpty(model.VendorEmail)) { Emails.Add(model.VendorEmail); } if (!string.IsNullOrEmpty(model.UserEmail)) { Emails.Add(model.UserEmail); } if (string.IsNullOrEmpty(model.VendorEmail) && string.IsNullOrEmpty(model.UserEmail)) { return; } string from = "Nuvem Notification Services"; /* Si deseamos Adjuntar algún archivo*/ //mnsj.Attachments.Add(new Attachment(pdfFile)); string msj = ""; using (WebClient client = new WebClient()) { var protocol = HttpContext.Current.Request.IsSecureConnection ? "https:" : "http:"; var path = HttpContext.Current.Request.Url.AbsolutePath; var port = HttpContext.Current.Request.Url.Port; var host = HttpContext.Current.Request.Url.Host + ((port == 80) ? "" : ":" + port.ToString()); path = host + @"/" + path.Substring(0, path.IndexOf(@"api/")) + @"/EmailAcceptedOffer"; path = path.Replace(@"//", @"/"); path = protocol + @"//" + path; var url = path + string.Format("?q={0}&v={1}", model.QHeaderKey, model.VendorKey); msj = client.DownloadString(url); } MailHelper.SendToEnqueue(subject, Emails, msj, from); } catch (Exception ex) { while (ex != null) { LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message); ex = ex.InnerException; } } }
private void SendMailActivation(string userEmail, string userPassword) { try { NuvemMailMessage msg = new NuvemMailMessage(); List <string> Emails = new List <string>(); string subject = "Nuvem B2B"; Emails.Add(userEmail); string from = "Nuvem Activation Services"; /* Si deseamos Adjuntar algún archivo*/ //mnsj.Attachments.Add(new Attachment(pdfFile)); string msj = ""; using (WebClient client = new WebClient()) { var protocol = HttpContext.Current.Request.IsSecureConnection ? "https:" : "http:"; var host = HttpContext.Current.Request.Url.Host; var path = HttpContext.Current.Request.Url.AbsolutePath; path = host + @"/" + path.Substring(0, path.IndexOf(@"api/")) + @"/EmailActivation"; path = path.Replace(@"//", @"/"); path = protocol + @"//" + path; msj = client.DownloadString(path + "?token=" + Uri.EscapeDataString(GenToken(userEmail, userPassword))); } /* Enviar */ MailHelper.SendToEnqueue(subject, Emails, msj, from); //System.IO.File.Delete(pdfFile); } catch (Exception ex) { while (ex != null) { LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message); ex = ex.InnerException; } } }