public SendResult Send(JMessage msg) { using (var resFileService = SiteManager.Get <ResourceFileService>()) { string sendto = String.Join(";", msg.SendToIds.Select(s => AppManager.Instance.UserManager.GetById(s.ToString())) .Where(u => !u.Email.IsEmpty()) .Select(u => (u.Name + "<" + u.Email + ">"))); var fromUser = AppManager.Instance.UserManager.GetById(msg.SenderId.ToString()); string from = fromUser == null ? null : fromUser.Email; string ccto = String.Join(";", msg.CopyToIds.Select(s => AppManager.Instance.UserManager.GetById(s.ToString())) .Where(u => !u.Email.IsEmpty()) .Select(u => (u.Name + "<" + u.Email + ">"))); SMTPMail mail = new SMTPMail(from, sendto, ccto, msg.Title, msg.Content, resFileService.GetFilePath((msg.AttachmentIds ?? new int[0]).ToArray())); mail.Send(); SendResult result = new SendResult { FailedReason = mail.ErrorMessage, MessageId = msg.Id, SentTime = DateTime.Now, PlanSendTime = msg.PlanSendTime, }; if (!mail.ErrorMessage.IsEmpty()) { result.FailedIds = msg.SendToIds.Union(msg.CopyToIds); } return(result); } }
public void SendMail() { SMTPMail mail = new SMTPMail("*****@*****.**", "Hello myself", "test send mail to my self"); mail.Send(); Debug.WriteLine("The Return Message Is: " + mail.ErrorMessage); Assert.IsTrue(mail.ErrorMessage.IsEmpty()); }
public void SendMail(string mailTo, string mailCc, string mailSubject, string mailBody, string replyto, System.Net.Mail.Attachment[] atts, string img_path, string tip) { SMTPMail mail = new SMTPMail(); mail.to = mailTo; mail.subject = mailSubject; mail.body = mailBody; mail.cc = mailCc; mail.reply_to = replyto; mail.attacments = atts; mail.imgpath = img_path; mail.tip = tip; System.Threading.ThreadPool.SetMaxThreads(20, 0); System.Threading.ThreadPool.QueueUserWorkItem(new WaitCallback(mail.SendMail)); }
public static void Main(string[] args) { var filepath = Directory.GetCurrentDirectory(); var file = Path.Combine(filepath, "oauthconfig.json"); AppSettings.ReadConfigurationSettings(file); var name = "Shannon Whalen"; var email = "*****@*****.**"; var body = "Email Body"; var subject = "Email Subject"; SMTPMail.SendMail(body, subject, name, email, name, email); if (Debugger.IsAttached) { Console.WriteLine("Please type any key:"); Console.Read(); } }
public ActionResult Dangki(taikhoan tk) { if (ModelState.IsValid) { bool kt = new TaikhoanController().KiemTraTenDangKi(tk.nguoidung); if (kt == false) { tk.id = Guid.NewGuid(); tk.Quyen = 0; bool kq = new TaikhoanController().DangKiUserKhach(tk); string d = Url.Action("Actived", "LoginUser", new { id = tk.id }, Request.Url.Scheme); string link = string.Format("Dear {0}<BR/>Thank you for your registration, please click on the below link to comlete your registration: <a href=\"{1}\" title=\"User Email Confirm\">{1}</a>", tk.nguoidung, Url.Action("Actived", "LoginUser", new { id = tk.id }, Request.Url.Scheme)); bool b = new SMTPMail().sendmail(tk.email, "chúc mừng bạn ", link, null); } } return(RedirectToAction("Index", "Home")); }
public virtual LoginState SendPasswordResetMessage(string userName, string email, string resetUrl) { var _context = new ModelContext(); MemberShip member = _context.Set <MemberShip>().FirstOrDefault(m => m.UserName.Equals(userName, StringComparison.OrdinalIgnoreCase) && m.IsConfirmed == true); if (member == null) { return(LoginState.UserNotExist); } if (!member.Email.Equals(email, StringComparison.OrdinalIgnoreCase)) { return(LoginState.EmailError); } member.ConfirmationToken = CommOp.NewId(); string url = resetUrl + "?username="******"&confirmToken=" + member.ConfirmationToken; string subject = ResHelper.GetStr("Password+Reset"); string body = "<p>" + ResHelper.GetStr("Click the link below to reset your password") + "</p>" + "<p>" + "<a href='" + url + "' target='_blank'>" + url + "</a></p>"; SMTPMail mail = new SMTPMail(member.Email, subject, body); _context.SaveChanges(); mail.Send(); if (mail.ErrorMessage.IsEmpty()) { return(LoginState.OK); } else { #if DEBUG if (HttpContext.Current != null) { HttpContext.Current.Session["ResetPasswordEmailBody"] = body; } #endif return(LoginState.EmailSendError); } }
public void SendSMTPMail(string to, string cc, string subject, string body, string reply_to, System.Net.Mail.Attachment[] att, string img_path, string tip) { SMTPMail smtp_mail = new SMTPMail(); smtp_mail.SendMail(to, cc, subject, body, reply_to, att, img_path, tip); }