internal static void sendEmailToAffi(Product.ProudctType productType) { var emailServer = getSMTPServer(); IMailService mailService = new SmptMailService(emailServer); MailContent mail = new MailContent(); mail.MailingAdress = getAFFIToAddress(); mail.MailFrom = getFromAddress(); mail.ReplyToAddress = getReplyToAddress(); //AFFI English //if (productType == Product.ProudctType.AffiEnglish) //{ mail.Subject = getAFFIEmailSubject(); mail.HtmlText = getEmaiBodyforAffi(); //} //AFFI Spanish //else //{ // mail.Subject = getAFFISpanishEmailSubject(); // mail.HtmlText = getEmaiBodyforAffiSpanish(); //} mailService.sendMail(mail, true); }
internal static void sendEmailToUser(string email, Product.ProudctType productType) { var emailServer = getSMTPServer(); IMailService mailService = new SmptMailService(emailServer); MailContent mail = new MailContent(); mail.MailingAdress = email; mail.MailFrom = getFromAddress(); mail.ReplyToAddress = getReplyToAddress(); //AFFI English if (productType == Product.ProudctType.AffiEnglish) { mail.Subject = getAFFIEmailSubject(); mail.HtmlText = getEmailBodyForUserAFFISite(); } //AFFI Spanish else { mail.Subject = getAFFISpanishEmailSubject(); mail.HtmlText = getEmailBodyForUserAFFISpanishSite(); } mailService.sendMail(mail, true); }
private bool FetchInfoAndSendMail(FileInfo file) { MailContent mailContent = FetchMailContent(file); MailSettings mailSettings = FetchMailSettings(); return(SendMail(mailContent, mailSettings)); }
public BE_Json PruebaMail([FromBody] MailContent mailContent) { BE_Json objJson = null; var objListaAux = string.Empty; try { BL_Mail bL_Mail = new BL_Mail(); bL_Mail.connectionString = AppConfig.DbConnection; objListaAux = JsonConvert.SerializeObject(bL_Mail.PruebaMail(mailContent)); objJson = new BE_Json(); objJson.data = objListaAux; objJson.status = CManager.RESULTADO_WCF.OK; } catch (Exception ex) { objJson = new BE_Json(); objJson.data = "Hubo en error en servidor:" + ex.Message + ";" + ex.StackTrace + ";" + ex.ToString(); objJson.status = CManager.RESULTADO_WCF.ERROR; objJson.status = CManager.RESULTADO_WCF.ERROR; } finally { objListaAux = null; } return(objJson); }
public async Task SendMail(MailContent mailContent) { var email = new MimeMessage(); email.Sender = new MailboxAddress(mailSettings.DisplayName, mailSettings.Mail); email.From.Add(new MailboxAddress(mailSettings.DisplayName, mailSettings.Mail)); email.To.Add(MailboxAddress.Parse(mailContent.To)); email.Subject = mailContent.Subject; var builder = new BodyBuilder(); builder.HtmlBody = mailContent.Body; email.Body = builder.ToMessageBody(); using var smtp = new MailKit.Net.Smtp.SmtpClient(); try { smtp.Connect(mailSettings.Host, mailSettings.Port, MailKit.Security.SecureSocketOptions.StartTls); smtp.Authenticate(mailSettings.Mail, mailSettings.Password); await smtp.SendAsync(email); } catch (Exception ex) { System.IO.Directory.CreateDirectory("mailssave"); var emailsavefile = string.Format(@"mailssave/{0}.eml", Guid.NewGuid()); await email.WriteToAsync(emailsavefile); Console.WriteLine(ex); } smtp.Disconnect(true); }
public MsgEntity SendMail(MailContent mailContent) { MsgEntity r; string sessionName = WebConfigurationManager.AppSettings["loginSessionName"]; if (HttpContext.Current.Session[sessionName] != null) { SendMail sendMail = new SendMail(); string toEmail = mailContent.toEmail; string[] cc = mailContent.cc; string title = mailContent.title; string content = mailContent.content; if (sendMail.Do(toEmail, cc, title, content)) { r = ResponseMsg.SetEntity(out r, 5000); } else { r = ResponseMsg.SetEntity(out r, 5101); } } else { ResponseMsg.SetEntity(out r, 4102); } return(r); }
public MailContentType(MailContent m) : base(m) { if (m == null || m.IsValid == false) { this.m_IsNull = true; return; } this.m_ID_MAILIsNull = !m.IdMail.HasValue; this.m_FOLLOWSIsNull = !m.Follows.HasValue; this.m_REF_ID_COMIsNull = !m.RefIdComunicazione.HasValue; this.m_FLG_ANNULLAMENTO = Convert.ToInt32(m.IsCancelled).ToString(); this.m_FLG_CUSTOM_REFS = Convert.ToInt32(m.HasCustomRefs).ToString(); if (m.MailRefs == null) { this.m_MAIL_REFS = MailRefsListType.Null; } else { this.m_MAIL_REFS = new MailRefsListType(); this.m_MAIL_REFS.MailRefs = m.MailRefs.Select(mr => (MailRefsType)mr).ToArray(); } }
public async Task <BaseResponse> SaveFeedback(FeedbackRequest feedbackRequest) { try { baseResponse = new BaseResponse(); using (FacepinpointDBEntities db = new FacepinpointDBEntities()) { Feedback feedback = new FacePinPoint.Repository.Feedback(); feedback.Email = feedbackRequest.Email; feedback.Message = feedbackRequest.Message; feedback.CreatedDate = DateTime.Now; db.Feedbacks.Add(feedback); await db.SaveChangesAsync(); //var templateResponse = db.Database.SqlQuery<TemplateDetail>("SELECT \"TemplateId\", \"TemplateName\", \"Subject\", \"Template\", \"Active\" FROM public.\"EmailTemplates\" where \"TemplateName\"= 'Subscription';").FirstOrDefault(); // var templateResponse = await db.EmailTemplates.Select(x => new TemplateDetail { Active = x.Active, Subject = x.Subject, Template = x.Template, TemplateId = x.TemplateId, TemplateName = x.TemplateName }).Where(x => x.TemplateName == "FeedBack").FirstOrDefaultAsync(); var templateResponse = await db.Database.SqlQuery <FacePinPoint.Entities.Response.TemplateDetail>("SELECT \"TemplateId\", \"TemplateName\", \"Subject\", \"public\".\"fn_GetUserEmail\"('FeedBack','" + feedbackRequest.Email + "') AS \"Template\", \"Active\" from \"public\".\"EmailTemplates\" where \"TemplateName\"='FeedBack'").FirstOrDefaultAsync(); mailContent = new MailContent(); mailContent.ToEmail = feedbackRequest.Email; mailContent.MsgSubject = templateResponse.Subject; mailContent.MsgBody = templateResponse.Template; // Email sender EmailSender.MailSender(mailContent); } } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); baseResponse.Success = false; baseResponse.Message = CustomErrorMessages.INTERNAL_ERROR; } return(baseResponse); }
//TODO: Incomplete... public static MailRequest ToMailRequest(this MailContent mailContent) { var request = new MailRequest { sender = mailContent.Senders == null ? null : String.Join(",", mailContent.Senders), receivers = mailContent.Receivers == null ? null : String.Join(",", mailContent.Receivers), subject = mailContent.Subject, html = mailContent.Html, text = mailContent.Text, cc = mailContent.Copies == null ? null : String.Join(",", mailContent.Copies), bcc = mailContent.BlindCopies == null ? null : String.Join(",", mailContent.BlindCopies) }; //Subject if (mailContent.Subject != null) { request.subject = mailContent.Subject; } //Body if (mailContent.Html != null) { request.text = mailContent.Html; } else if (mailContent.Text != null) { request.text = mailContent.Text; } return(request); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapGet("/", async context => { await context.Response.WriteAsync("Hello World!"); }); endpoints.MapGet("/testmail", async context => { // Lấy dịch vụ sendmailservice var sendmailservice = context.RequestServices.GetService <ISendMailService>(); MailContent content = new MailContent { To = "*****@*****.**", Subject = "Kiểm tra thử", Body = "<p><strong>Xin chào xuanthulab.net</strong></p>" }; await sendmailservice.SendMail(content); await context.Response.WriteAsync("Send mail"); }); }); }
public async Task <IHttpActionResult> SendMailToUser(MailContent obj) { SendMail s = new SendMail(); await s.SendMails(obj.Body, obj.Destination, obj.Subject); return(Ok()); }
public static bool Send_FriendMail(MailContent MailContent, string To, string Subject, string Message) { MailContent.To = MailContent.To.Replace("||TO||", To); MailContent.Subject = MailContent.Subject.Replace("||SUBJECT||", Subject); MailContent.Body = GetSubjectMaster(Message); return(Send_SimpleHtml(MailContent, To, "", "", MailPriority.High)); }
private static MailContent createVendorReportEmail(Vendor vendor, String recipient, UserPurchase user, int categoryId) { MailContent mailContent = new MailContent(); mailContent.MailFrom = vendorsContactEmail; mailContent.MailingAdress = recipient; QuestionnaireContext _context = new QuestionnaireContext(); String sectionName = (categoryId != 0) ? _context.Categories.Where(x => x.Id == categoryId).First().Title : "General List of ‘Suggested Service Providers’"; mailContent.Subject = "Referral from AFFI-FSMA Assessments – Request for Information"; mailContent.HtmlText = "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" style=\"width: 600px;\">" + "<tbody><tr><td>" + "<img alt=\"\" src=\"http://affi-fsma.seneca.com/Content/img/affi_logo.jpg\" style=\"width: 100px; height: 73px;\" /></td>" + "<td><div><span style=\"font-size:18px;\"><strong>Responses from the AFFI – FSMA Self Assessment</strong></span></div>" + "<div><span style=\"font-size:18px;\"><strong>Request for Information to “Suggested Service Provider”</strong></span></div>" + "</td></tr></tbody></table><br/>" + "<span style=\"font-size:16px;\">TO: " + vendor.Name + "<br/><br/>" + "The following person has clicked on the “Contact Me” button while taking the AFFI – FSMA Self-Assessment:<br/><br/>" + "Name of person: " + user.Name + "<br/>" + "Facility name: " + user.FacilityName + "<br/>" + "Email address: " + user.Email + "<br/>" + "Date and time: " + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToShortTimeString() + "<br/><br/>" + "Section of the AFFI – FSMA Self-Assessment Report: " + sectionName + "<br/><br/>" + "By clicking on the Contact Me button the person anticipates that they will receive information about your company’s services related to the section of the FSMA Self-Assessment Report as referenced above.<br/><br/>" + "If you have any questions about this email, please “Reply” to this email with your questions.<br/><br/>" + "Thank you – <br/>" + "Seneca Corporation</span>"; return(mailContent); }
public void ImapSslTls_TestRunDownloadContentAsyncLoop() { MailContent mailContent = null; var mailController = CreateMailController(); try { mailController.Start(MailServerType.Imap, MailServerEncryption.SslTls, _host, _user, _password); mailContent = mailController.MailContentStream.Take(1).Timeout(DateTime.Now.AddSeconds(60)).Wait(); } catch (Exception e) { Debug.WriteLine(e); mailContent = null; } finally { mailController.Dispose(); } Debug.WriteLine($"[{mailContent.Date}] {mailContent.Uid} | Subject: {mailContent.Text}"); if (mailContent == null) { Assert.Fail(); } }
public async Task <MailContent> GetContent(GetContentRequest request) { int userId = User.Identity.GetClaims().Id; var isValidOwner = _mailBoxValidator.IsValidOwner(request.Id, userId); Log.Reports(isValidOwner.Reports, Request); if (isValidOwner.Value == false) { return(null); } MailContent mailContent; using (_db) { // Get mail content var mail = _db.Mails.Find(request.Id); mailContent = new MailContent { Id = mail.Id, Message = mail.Message }; // Mark email as read if needed if (mail.ToId == userId && mail.ToStatus == MailStatuses.New) { Log.Info(LogTag.MailMarkedAsRead, Request, new { userId, mailId = mail.Id }); mail.ToStatus = MailStatuses.Read; await _db.SaveChangesAsync(); } } return(mailContent); }
// Gửi email, theo nội dung trong mailContent public async Task SendMail(MailContent mailContent) { var email = new MimeMessage(); email.Sender = MailboxAddress.Parse(mailSettings.Mail); email.To.Add(MailboxAddress.Parse(mailContent.To)); email.Subject = mailContent.Subject; var builder = new BodyBuilder(); builder.HtmlBody = mailContent.Body; email.Body = builder.ToMessageBody(); // dùng SmtpClient của MailKit using var smtp = new MailKit.Net.Smtp.SmtpClient(); try { smtp.Connect(mailSettings.Host, mailSettings.Port, SecureSocketOptions.StartTls); smtp.Authenticate(mailSettings.Mail, mailSettings.Password); await smtp.SendAsync(email); } catch (Exception ex) { logger.LogInformation("Lỗi gửi mail"); logger.LogError(ex.Message); } smtp.Disconnect(true); logger.LogInformation("send mail to " + mailContent.To); }
/// <summary> /// 发送邮件 /// </summary> /// <param name="msg"></param> /// <param name="IsForce">是否强制发送</param> /// <returns></returns> private async Task SendEmail(string msg) { Console.WriteLine("{0} {1} {2} 发送邮件!", this.Url.ToString(), this.Name, msg); var sendModel = new MailContent(this.Name, this.Url.ToString(), msg); var pubs = new BastPush(sendModel); await pubs.SendAsync(); }
public static bool Send_Tmp_WelcomeMessage(MailContent MailContent, string FirstName, string LastName, string To) { MailContent.Body = MailContent.Body.Replace("||FirstName||", FirstName.ToString()); MailContent.Body = MailContent.Body.Replace("||LastName||", LastName.ToString()); MailContent.Body = GetSubjectMaster(MailContent.Body); return(Send_SimpleHtml(MailContent, To, "", "", MailPriority.High)); }
public static bool Send_Tmp_ForgotPassCompany(MailContent MailContent, string Password, string FirstName, string LastName, string To) { MailContent.Body = MailContent.Body.Replace("||PASSWORD||", Password); MailContent.Body = MailContent.Body.Replace("||FirstName||", FirstName); MailContent.Body = MailContent.Body.Replace("||LastName||", LastName); MailContent.Body = GetSubjectMaster(MailContent.Body); return(Send_SimpleHtml(MailContent, To, "", "", MailPriority.High)); }
private void sendEmails(Vendor vendor, UserPurchase user, int categoryId) { MailContent vendorMailContent = MailConfigurator.createVendorReport(vendor, user, categoryId); MailContent vendorAdminMailContent = MailConfigurator.createVendorAdminReport(vendor, user, categoryId); mailService.sendMail(vendorMailContent, true); mailService.sendMail(vendorAdminMailContent, true); }
public static bool Send_Tmp_TemporaryUser(MailContent MailContent, string UserName, string Password, string Notes, string To) { MailContent.Body = MailContent.Body.Replace("||USERNAME||", UserName); MailContent.Body = MailContent.Body.Replace("||PASSWORD||", Password); MailContent.Body = MailContent.Body.Replace("||NOTES||", Notes); MailContent.Body = GetSubjectMaster(MailContent.Body); return(Send_SimpleHtml(MailContent, To, "", "", MailPriority.High)); }
public static bool Send_Tmp_ActivationCompany(MailContent MailContent, string ActivationCode, int CompanyID, string FirstName, string LastName, string To) { MailContent.Body = MailContent.Body.Replace("||ACTIVATIONCODE||", ActivationCode); MailContent.Body = MailContent.Body.Replace("||COMPANYID||", CompanyID.ToString()); MailContent.Body = MailContent.Body.Replace("||FirstName||", FirstName); MailContent.Body = MailContent.Body.Replace("||LastName||", LastName); MailContent.Body = GetSubjectMaster(MailContent.Body); return(Send_SimpleHtml(MailContent, To, "", "", MailPriority.High)); }
public static MailContent createManagerReportEmail(UserPurchase user, QuestionnaireReport report) { MailContent mailContent = new MailContent(); mailContent.MailFrom = adminEmail; mailContent.MailingAdress = adminEmail; mailContent.Subject = "FSMA Self Assessment Report for " + user.FacilityName; return(mailContent); }
public string PruebaMail(MailContent mailContent) { _database = new MySQLDatabase(connectionString); var mail = new DA_Mail(_database).GetMail(mailContent.mailId); var newMailBody = mail.bodyMail.Replace("@prueba", mailContent.prueba); return(newMailBody); }
public void StoreMails(MailContent content) { try{ var collection = CommunicationService.DBase.GetCollection <MailContent>("Mails"); collection.InsertOne(content); } catch { throw new Exception("Mails have not been saved properly"); } }
public ParsedMail(MessageEventArgs args) { FromUser = new MailUser(args.Message.From); ToUser = new MailUser(args.Message.To[0]); using (var stream = args.Message.GetData()) { Content = new MailContent(stream); } Subject = new MailSubject(Content); }
public string SelectMail(MailContent mailContent) { if (mailContent.mailId == 5) { return(PruebaMail(mailContent)); } else { return("Código no encontrado"); } }
public IActionResult Post([FromBody] MailContent mailContent) { _publisher.SendAsync <IMailCommand>(mailContent, mailContent.ContentType.ToString().ToLower()).Wait(); return(Ok(new { Success = true, Code = HttpStatusCode.OK, Message = "Queued for Delivery" } )); }
public async Task SendMail(MailContent mailContent) { var email = new MimeMessage(); email.Sender = new MailboxAddress(_mailSetting.DisplayName, _mailSetting.Mail); email.From.Add(new MailboxAddress(_mailSetting.DisplayName, _mailSetting.Mail)); email.To.Add(MailboxAddress.Parse(mailContent.To)); email.Subject = mailContent.Subject; var builder = new BodyBuilder(); builder.HtmlBody = mailContent.Body; email.Body = builder.ToMessageBody(); //builder.TextBody = @"Hey Alice, // What are you up to this weekend? Monica is throwing one of her parties on // Saturday and I was hoping you could make it. // Will you be my +1? // -- Joey // "; //// image from local //var image = builder.LinkedResources.Add(@"C:\Users\Admin\Pictures\Saved Pictures\Capture.PNG"); //image.ContentId = MimeUtils.GenerateMessageId(); //builder.HtmlBody = string.Format(@"<p>Hey Alice,<br> // <p>What are you up to this weekend? Monica is throwing one of her parties on // Saturday and I was hoping you could make it.<br> // <p>Will you be my +1?<br> // <p>-- Joey<br> // <img src=""https://otaku2d.com/wp-content/uploads/2020/11/haki-zoro-4.jpg"" /> // <center><img src=""cid:{0}""></center>", image.ContentId); ////Đính ke //builder.Attachments.Add(@"C:\Users\Admin\Desktop\DOC\password.txt"); //email.Body = builder.ToMessageBody(); //smtp using var smtp = new MailKit.Net.Smtp.SmtpClient(); try { // SecureSocketOptions cung cấp 1 cách xác định SSL và/ hoặc TLS smtp.Connect(_mailSetting.Host, _mailSetting.Port, SecureSocketOptions.StartTls); smtp.Authenticate(_mailSetting.Mail, _mailSetting.Password); await smtp.SendAsync(email); } catch (Exception) { throw; } smtp.Disconnect(true); }
public async Task <string> SendEmail() { MailContent content = new MailContent { To = "*****@*****.**", Subject = "Kiểm tra thử", Body = "<p><strong>Xin chào xuanthulab.net</strong></p>" }; await sendMailService.SendMail(content); return("ok"); }