protected void btnSendMail_Click(object sender, EventArgs e) { try { EmailSend email = new EmailSend(); email.fromEmail = ip_txt_from_email.Value; email.toEmail = ip_txt_to_email.Value; email.passWordSendMail = ip_txt_pass_email.Value; email.subject = ip_txt_subject.Value; email.body = txt_content_mail.Value; if (radio_service_google.Checked) { GoogleMailService.sendMail("*****@*****.**", createEmail.createMessage(email.subject , email.body , email.fromEmail , email.toEmail)); } else if (radio_service_stpm.Checked) { STPMService.SendMail(email.fromEmail , email.passWordSendMail , email.toEmail , email.subject , email.body); } string message = "Gửi email thành công"; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + message + "');", true); } catch (Exception v_e) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + v_e + "');", true); Debugger.Log(1, "Send Mail", "Failed: " + v_e); } }
public CaptchaHelperModel SendAuthCode(CaptchaEnum captchaEnum, int accId, CaptchaPhoneEmailEnum typeEnum, string phoneOrEmail) { var redisCacheService = new RedisCacheService(); if (string.IsNullOrWhiteSpace(phoneOrEmail)) { throw new ArgumentNullException("phoneOrEmail", "手机号码邮箱地址为空"); } //获取失败次数 var strWrongTimesKey = GetWrongTimesKey(captchaEnum, accId); int iWrongTimes = redisCacheService.Get <int>(strWrongTimesKey); //判断验证码错误次数 if (iWrongTimes > _checkWrongTimes) { return(new CaptchaHelperModel(false, "验证码错误次数过多,请1小时后重试或联系客服", typeEnum)); } //获取验证码key var strCaptchaKey = GetCaptchaKey(captchaEnum, accId, phoneOrEmail); if (string.IsNullOrEmpty(strCaptchaKey)) { return(new CaptchaHelperModel(false, "错误的手机号或邮箱", typeEnum)); } //判断是否之前发过验证码 int iCaptcha = redisCacheService.Get <int>(strCaptchaKey); if (iCaptcha == 0) { iCaptcha = Helper.GetInt32(Helper.GetRandomNum(), 111111); } var smsStr = string.Format("【生意专家】您本次获取的验证码为:{0},此验证码{1}分钟内有效。维护您的数据安全是生意专家义不容辞的责任。", iCaptcha, _outTimeMinutes); var mailSend = new EmailSend(); var smsSend = new SmsSend(); var result = typeEnum == CaptchaPhoneEmailEnum.Phone ? smsSend.SendSys(phoneOrEmail, smsStr, 13) : mailSend.SendVerifiEmail(accId, "", phoneOrEmail, iCaptcha.ToString()); if (result) { _logger.Debug("发送验证码成功:" + iCaptcha); redisCacheService.Set(strCaptchaKey, iCaptcha, _outTimeMinutes * 60); return(new CaptchaHelperModel(true, "发送验证码成功", CaptchaPhoneEmailEnum.Email)); } else { return(new CaptchaHelperModel(false, "发送失败", CaptchaPhoneEmailEnum.Email)); } }
public async Task SendEmail([FromRoute] EmailSend parameters) { var emlNode = await _alfrescoHttpClient.GetNodeInfo(parameters.NodeId, ImmutableList <Parameter> .Empty .Add(new Parameter(AlfrescoNames.Headers.Include, AlfrescoNames.Includes.Path, ParameterType.QueryString))); if (emlNode?.Entry?.Path?.Name.StartsWith(AlfrescoNames.Prefixes.Path + SpisumNames.Paths.MailRoomEmail, StringComparison.OrdinalIgnoreCase) == false) { throw new BadRequestException("", "Node is not in Mailroom"); } var emailProperties = emlNode.Entry.Properties.As <JObject>().ToDictionary(); if (emailProperties.GetNestedValueOrDefault(SpisumNames.Properties.EmailSender) == null) { throw new BadRequestException(ErrorCodes.V_EMAIL_NO_SENDER); } if (emailProperties.GetNestedValueOrDefault(SpisumNames.Properties.EmailRecipient) == null) { throw new BadRequestException(ErrorCodes.V_EMAIL_NO_RECIPIENT); } string senderEmail = emailProperties.GetNestedValueOrDefault(SpisumNames.Properties.EmailSender).ToString(); string recipientEmail = emailProperties.GetNestedValueOrDefault(SpisumNames.Properties.EmailRecipient).ToString(); if (!EmailUtils.IsValidEmail(senderEmail)) { throw new BadRequestException(ErrorCodes.V_EMAIL_INVALID_SENDER); } if (!EmailUtils.IsValidEmail(recipientEmail)) { throw new BadRequestException(ErrorCodes.V_EMAIL_INVALID_RECIPIENT); } var emailConfiguration = (await _emailHttpClient.Accounts())?.FirstOrDefault(x => x?.Username?.ToLower() == recipientEmail?.ToLower()); if (emailConfiguration == null) { throw new BadRequestException(ErrorCodes.V_EMAIL_NO_CONFIGURATION); } if (emlNode?.Entry?.Path?.Name?.Equals(AlfrescoNames.Prefixes.Path + SpisumNames.Paths.MailRoomEmailUnprocessed) != true) { throw new BadRequestException("", "Node is not in expected path"); } await _emailHttpClient.Send(senderEmail, emailConfiguration.Username, parameters.Subject, parameters.Body, parameters.Files); // Move eml and children await _nodesService.MoveChildrenByPath(emlNode.Entry.Id, SpisumNames.Paths.MailRoomEmailNotRegistered); await _alfrescoHttpClient.UpdateNode(parameters.NodeId, new NodeBodyUpdate { Properties = new Dictionary <string, object> { { SpisumNames.Properties.EmailNotRegisteredReason, "EM_VAL_01" } } } ); }
public async Task <ActionResult> Register(RegisterAdmin reg) { reg.Email.Trim(); AbzContext db = new AbzContext(); Usr user = new Usr(); user.Email = reg.Email; string Password = GenerateRandomPassword(6); user.Password = Password; user.UserId = Guid.NewGuid().ToString(); db.Users.Add(user); db.SaveChanges(); UserInCust uc = new UserInCust(); uc.CustID = reg.CustId; uc.UserId = user.UserId; uc.LastDat = DateTime.Now; uc.Email = reg.Email; //uc.Pwd = Password; db.UserInCusts.Add(uc); db.SaveChanges(); await EmailSend.EMailRegAsync(reg.Email, Password); return(RedirectToAction("Index", "Home")); }
public HrApiController() { c = new HRController(); emailsend = new EmailSend(); feedInterface = new FeedbackRepository(); }
public async Task <IActionResult> Send(SendRequest sendRequest) { //初使化 Initialize(sendRequest); var email = EmailSend .From(sendRequest.FromEmail) .To(sendRequest.ToEmail) .Body(sendRequest.Body, true); //使用模板发送 if (sendRequest.TemplateModel != null && !string.IsNullOrEmpty(sendRequest.Template)) { email.UsingTemplate(sendRequest.Template, sendRequest.TemplateModel); } //发送附件 if (sendRequest.Attachment != null) { email.Attach(sendRequest.Attachment); } var response = await email.SendAsync(); return(new JsonResult(response)); }
public static void ProductAvailable(string productName, string[] emails) { var emailMessage = StaticContents.GetContentByName("ProductAvailable"); if (emailMessage != null && emailMessage != "نا مشخص") { emailMessage = emailMessage.Replace("{{Name}}", productName); List <EmailSend> list = new List <EmailSend>(); foreach (var item in emails) { var emailSend = new EmailSend { EmailSendStatus = EmailSendStatus.NotChecked, FromID = SaleMail.ID, LastUpdate = DateTime.Now, Priority = Priority.Medium, Subject = "دعوت به خرید", Text = emailMessage, To = item }; list.Add(emailSend); } EmailSends.InsertGroup(list); } }
public void NofityBll() { var send = new EmailSend(); var nofity = new UserNotification(send); nofity.Notify("注册了用户"); }
private void SendMail(Ad ad, object reservation) { EmailSend emailSend = new EmailSend(); emailSend.SendEmail(ad, reservation); emailSend.CloseConnection(); }
protected void change_ServerClick(object sender, EventArgs e) { if (validateNum.Value == Session["CheckCode"].ToString()) { MembershipCreateStatus status; Membership.CreateUser(userTxt.Value, password.Value, email.Value, question.Value, answer.Value, true, out status); if (status == MembershipCreateStatus.Success) { try { EmailSend es = new EmailSend(); es.sendRegEmail(email.Value, userTxt.Value, password.Value); } catch (Exception ee) { } finally { MultiView1.ActiveViewIndex = 3; Address.InsertAddress(userTxt.Value); Roles.AddUserToRole(userTxt.Value, "Member"); } } if (status == MembershipCreateStatus.DuplicateEmail) { DuplicateEmailTxt.Text = "此Email已被注册,请选择填写Email"; } } else { validateNumTxt.Text = "验证码输入有误,请重新输入验证码"; } }
/*Name of Function : <<sendASNMailtoBuyer> Author :<<Prasanna>> * Date of Creation <<27-11-2020>> * Purpose : <<Sending mail method>> * Review Date :<<>> Reviewed By :<<>>*/ public bool sendASNMailtoBuyer(int ASNId) { try { VSCMEntities vscm = new VSCMEntities(); var mpripaddress = ConfigurationManager.AppSettings["UI_IpAddress"]; mpripaddress = mpripaddress + "SCM/ASNView/" + ASNId + ""; using (var db = new YSCMEntities()) //ok { RemoteASNShipmentHeader ASNHeader = vscm.RemoteASNShipmentHeaders.Where(li => li.ASNId == ASNId).FirstOrDefault(); EmailSend emlSndngList = new EmailSend(); emlSndngList.FrmEmailId = ConfigurationManager.AppSettings["fromemail"]; emlSndngList.Subject = "ASNCreated"; emlSndngList.Body = "<html><head></head><body><div class='container'><p>Click below link to view details</p></div><br/><div><b style='color:#40bfbf;'>TO View Details: <a href='" + mpripaddress + "'>" + mpripaddress + "</a></b></div><br /><div><b style='color:#40bfbf;'></a></b></body></html>"; if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["ASNToEmail"])) { emlSndngList.ToEmailId = ConfigurationManager.AppSettings["ASNToEmail"]; } if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["ASNCCEmail"])) { emlSndngList.CC = ConfigurationManager.AppSettings["ASNCCEmail"]; } if ((!string.IsNullOrEmpty(emlSndngList.FrmEmailId) && !string.IsNullOrEmpty(emlSndngList.FrmEmailId)) && (emlSndngList.FrmEmailId != "NULL" && emlSndngList.ToEmailId != "NULL")) { this.sendEmail(emlSndngList); } } } catch (Exception ex) { log.ErrorMessage("EmailTemplate", "sendASNMailtoBuyer", ex.Message + "; " + ex.StackTrace.ToString()); } return(true); }
/// <summary> /// 获取验证码 /// </summary> /// <param name="email"></param> /// <returns></returns> public JsonBackResult GetCode(string email) { if (!RegularHelper.IsEmail(email)) { return(JsonBackResult(ResultStatus.EmailErr)); } var user = this._userWebService.GetList(t => t.EMail == email && t.State == 1).FirstOrDefault(); if (user != null) { return(JsonBackResult(ResultStatus.EmailExist)); } Tuple <string, bool> items = EmailSend.SendEmail(email, "Songbike网络博客", "用户注册码"); string code = items.Item1; Session.Add("VerifyCode", code); bool sendRes = items.Item2; if (sendRes) { bool res1 = CacheHelper.Set("RegCode", code, DateTime.Now.AddSeconds(90)); bool res2 = CacheHelper.Set("Email", email, DateTime.Now.AddSeconds(90)); if (res1 && res2) { return(JsonBackResult(ResultStatus.Success)); } } return(JsonBackResult(ResultStatus.Fail)); }
public bool sendCommunicationmailtoRequestor(int RFQRevisionId, string Remarks) { try { VSCMEntities yscmobj = new VSCMEntities(); var db = new YSCMEntities(); RemoteRFQRevisions_N rfqrevisiondetails = yscmobj.RemoteRFQRevisions_N.Where(li => li.rfqRevisionId == RFQRevisionId).FirstOrDefault <RemoteRFQRevisions_N>(); RemoteRFQMaster rfqmasterDetails = yscmobj.RemoteRFQMasters.Where(li => li.RfqMasterId == rfqrevisiondetails.rfqMasterId).FirstOrDefault <RemoteRFQMaster>(); var fromMail = ConfigurationManager.AppSettings["fromemail"]; var mpripaddress = ConfigurationManager.AppSettings["UI_IpAddress"]; mpripaddress = mpripaddress + "SCM/MPRForm/" + rfqmasterDetails.MPRRevisionId + ""; var rfqipaddress = ConfigurationManager.AppSettings["UI_IpAddress"]; rfqipaddress = rfqipaddress + "SCM/VendorQuoteView/" + rfqrevisiondetails.rfqRevisionId + ""; EmailSend emlSndngList = new EmailSend(); emlSndngList.Body = "<html><head></head><body><div class='container'><p>Comments by Vendor</p></div><br/>" + Remarks + " <br/><br/></div><b style='color:#40bfbf;'>TO View MPR: <a href='" + mpripaddress + "'>" + mpripaddress + "</a></b></div><br /><br/><div><b style='color:#40bfbf;'>TO View RFQ: <a href='" + rfqipaddress + "'>" + rfqipaddress + "</a></b></body></html>"; Employee Email = db.Employees.Where(li => li.EmployeeNo == rfqrevisiondetails.BuyergroupEmail).FirstOrDefault <Employee>(); emlSndngList.Subject = "Communication From Vendor on RFQNumber: " + rfqmasterDetails.RFQNo; // + mprrevisionDetail.RemoteRFQMaster.RFQNo; emlSndngList.FrmEmailId = fromMail; var toEMail = Convert.ToString(rfqrevisiondetails.CreatedBy); emlSndngList.ToEmailId = (db.Employees.Where(li => li.EmployeeNo == toEMail).FirstOrDefault <Employee>()).EMail; emlSndngList.CC = (db.Employees.Where(li => li.EmployeeNo == rfqrevisiondetails.BuyergroupEmail).FirstOrDefault <Employee>()).EMail; if ((!string.IsNullOrEmpty(emlSndngList.FrmEmailId) && !string.IsNullOrEmpty(emlSndngList.FrmEmailId)) && (emlSndngList.FrmEmailId != "NULL" && emlSndngList.ToEmailId != "NULL")) { this.sendEmail(emlSndngList); } } catch (Exception ex) { log.ErrorMessage("EmailTemplate", "sendmailtoRequestor", ex.Message + "; " + ex.StackTrace.ToString()); } return(true); }
public bool RespostaSugestao(SugestaoResposta resposta) { try { var email = new Email { ClienteEmail = resposta.Email, AssuntoEmail = String.Format("Resposta a sugestão #{0}", resposta.Id), ConteudoEmail = resposta.Mensagem }; var sucesso = new EmailSend().SendEmail(email); if (sucesso) { return(true); } else { return(false); } } catch (Exception) { return(false); } }
public bool sendMailtoBuyer(int VendorId) { try { using (var db = new YSCMEntities()) //ok { var mpripaddress = ConfigurationManager.AppSettings["UI_IpAddress"]; mpripaddress = mpripaddress + "SCM/VendorRegInitiate/" + VendorId + ""; var fromMail = ConfigurationManager.AppSettings["fromemail"]; VendorRegApprovalProcess vendorProcessDetails = db.VendorRegApprovalProcesses.Where(li => li.Vendorid == VendorId).FirstOrDefault(); EmailSend emlSndngList = new EmailSend(); emlSndngList.Subject = "Vendor Registration response"; emlSndngList.Body = "<html><head></head><body><div class='container'><p>Comments by Vendor</p></div><br/><div><b style='color:#40bfbf;'>TO View Details: <a href='" + mpripaddress + "'>" + mpripaddress + "</a></b></div><br /><div><b style='color:#40bfbf;'></a></b></body></html>"; emlSndngList.FrmEmailId = fromMail; emlSndngList.ToEmailId = (db.Employees.Where(li => li.EmployeeNo == vendorProcessDetails.IntiatedBy).FirstOrDefault <Employee>()).EMail; if ((!string.IsNullOrEmpty(emlSndngList.FrmEmailId) && !string.IsNullOrEmpty(emlSndngList.FrmEmailId)) && (emlSndngList.FrmEmailId != "NULL" && emlSndngList.ToEmailId != "NULL")) { this.sendEmail(emlSndngList); } } } catch (Exception ex) { log.ErrorMessage("EmailTemplate", "sendMailtoBuyer", ex.Message + "; " + ex.StackTrace.ToString()); } return(true); }
public async Task <IActionResult> Register([FromBody] RegisterViewModel model) { //if (!ModelState.IsValid) //{ // var errrors = CustomValidator.GetErrorsByModel(ModelState); // return BadRequest(errrors); //} var user = new DbUser { UserName = model.Email, Email = model.Email }; var result = await _userManager.CreateAsync(user, model.Password); if (!result.Succeeded) { return(BadRequest(result.Errors)); } await _signInManager.SignInAsync(user, isPersistent : false); EmailSend emailSend = new EmailSend(); await emailSend.SendEmailAsync(model.Email, "Confirm your account", "Confirm your account"); return(Ok( new { token = CreateTokenJwt(user) })); }
/// <summary> /// 找回密码发送验证码 /// </summary> /// <param name="email"></param> /// <returns></returns> public JsonBackResult FindUserInfo(string email) { if (!RegularHelper.IsEmail(email)) { return(JsonBackResult(ResultStatus.EmailErr)); } var user = this._userWebService.GetList(s => s.EMail == email).ToList().FirstOrDefault(); if (user == null) { return(JsonBackResult(ResultStatus.EmailNoExist, user)); } Tuple <string, bool> items = EmailSend.SendEmail(email, "SongBiKe网络博客", "用户找回密码验证码"); string code = items.Item1; Session.Add("ReVerifyCode", code); bool sendRes = items.Item2; if (sendRes) { bool res1 = CacheHelper.Set("PwdBackCode", code, DateTime.Now.AddSeconds(90)); bool res2 = CacheHelper.Set("PwdBackEMail", email, DateTime.Now.AddSeconds(90));//判断用户发送验证码和注册用的是同一个邮箱 if (res1 && res2) { return(JsonBackResult(ResultStatus.Success)); } } return(JsonBackResult(ResultStatus.Fail)); }
/*Name of Function : <<sendBGmail> Author :<<Prasanna>> * Date of Creation <<16-01-2021>> * Purpose : <<Sending mail to YIL members>> * Review Date :<<>> Reviewed By :<<>>*/ public bool sendBGmail(int bgId) { try { VSCMEntities vscm = new VSCMEntities(); using (var db = new YSCMEntities()) //ok { var mpripaddress = ConfigurationManager.AppSettings["UI_IpAddress"]; mpripaddress = mpripaddress + "SCM/BGView/" + bgId + ""; var fromMail = ConfigurationManager.AppSettings["fromemail"]; RemoteBankGuarantee BGDeatils = vscm.RemoteBankGuarantees.Where(li => li.BGId == bgId).FirstOrDefault(); var mailData = (db.Employees.Where(li => li.EmployeeNo == BGDeatils.CreatedBy).FirstOrDefault <Employee>()); EmailSend emlSndngList = new EmailSend(); emlSndngList.Subject = "BG Submitted For PONo:" + BGDeatils.PONo + "; BGNo:" + BGDeatils.BGNo + " "; emlSndngList.Body = "<html><head></head><body><div class='container'><p>Click below link to view details</p></div><br/><div><b style='color:#40bfbf;'>TO View Details: <a href='" + mpripaddress + "'>" + mpripaddress + "</a></b></div><br /><div><b style='color:#40bfbf;'></a></b><p style = 'margin-bottom:0px;' ><br/> Regards,</p><p> <b>" + BGDeatils.VendorName + "</b></p></body></html>"; emlSndngList.FrmEmailId = fromMail; emlSndngList.ToEmailId = mailData.EMail + ","; if (BGDeatils.BuyerManger != null) { emlSndngList.ToEmailId += (db.Employees.Where(li => li.EmployeeNo == BGDeatils.BuyerManger).FirstOrDefault <Employee>()).EMail; } if ((!string.IsNullOrEmpty(emlSndngList.FrmEmailId) && !string.IsNullOrEmpty(emlSndngList.FrmEmailId)) && (emlSndngList.FrmEmailId != "NULL" && emlSndngList.ToEmailId != "NULL")) { this.sendEmail(emlSndngList); } } } catch (Exception ex) { log.ErrorMessage("EmailTemplate", "sendASNCommunicationMail", ex.Message + "; " + ex.StackTrace.ToString()); } return(true); }
public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model) { if (ModelState.IsValid) { string qq = model.Email; var user = await UserManager.FindByNameAsync(model.Email); if (user == null) { return(View("Error")); } string newpassword = GenerateRandomPassword(6); string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id); var result = await UserManager.ResetPasswordAsync(user.Id, code, newpassword); if (result.Succeeded) { await EmailSend.EMailFPassw(model.Email, newpassword); return(View("ForgotPasswordConfirmation")); } } return(View(model)); }
public Task sendConfirmEmail(String emailto, String userId, String code) { HostingEnvironment.QueueBackgroundWorkItem(cancellationToken => { EmailSend.SendConfirmEmailAsync(emailto, userId, code); }); return(null); }
public void Close() { Thread.Sleep(8000); extent.Flush(); Thread.Sleep(3000); EmailSend.SendMail(); driver.Quit(); }
//[HttpPost] public async Task <IActionResult> Post() { BatchRequestResponse templateResponse = await _emailService.CreateTemplatesAsync(); if (!templateResponse.success) { return(StatusCode(500, templateResponse)); } var templateReturn = templateResponse.jsonData.FromJson <List <Template> >(); var templateData = new List <TemplateData>(); for (int i = 0; i < templateReturn.Count; i++) { var template = new TemplateData { TemplateId = templateReturn[i].id, Data = new Dictionary <string, object> { { "store_name", $"Grocery {i+1}" }, { "store_address", $"Address {i+1}" } } }; templateData.Add(template); } var emailSends = new List <EmailSend>(); foreach (var template in templateData) { var emailSend = new EmailSend { TemplateData = template, Recipients = new Collection <EmailRecipient> { new EmailRecipient(_config.Value.RecipientEmails[0]), new EmailRecipient(_config.Value.RecipientEmails[1]), }, Bccs = new Collection <EmailRecipient> { new EmailRecipient(_config.Value.RecipientEmails[2]) } }; emailSends.Add(emailSend); } BatchRequestResponse emailResponse = await _emailService.SendEmailsAsync(emailSends); if (!emailResponse.success) { return(StatusCode(500, emailResponse)); } return(Ok(emailResponse)); }
public void CacheItemRemoved(string taskName, object seconds, CacheItemRemovedReason removalReason) { var send_mail = new EmailSend(); { send_mail.send_expiry_mail(); } AddTask(taskName, Convert.ToInt32(seconds)); }
static void Main(string[] args) { string title = "Hello World!"; string content = "<div style=\"height:50px;width:100%;background:#333;color:#fff;text-align:center;line-height:50px;\">邮件Api发送测试, Hello_World!</div>"; EmailSend es = new EmailSend(fromEmail, authorization, sendtype); es.ToEmailList.Add(toEmail); TestSend(es, title, content); Console.ReadLine(); }
public void delete() { //删除信息 //要删除的纪录的ID,保存在delList隐藏控件内 string id = delList.Text; if (id != "") { data_conn cn = new data_conn(); string body = "尊敬的用户:<br/>"; body += "感谢您参与我们的论坛.<br/>"; body += "由于您在发布的帖子违反本论坛协议而被管理员删除.敬请谅解详情请见<a herf=\"www.100allin.com\">www.100allin.com</a><br/>"; body += "您在使用过程中,如有任何问题或建议,请随时联系傲赢网客户服务人员,我们将热忱为您服务。顺颂商祺!"; DataSet dsBBS = cn.mdb_ds("select UserEmail from TB_User,TB_BBS where TB_User.Userid=TB_BBS.Userid and TB_BBS.id in (" + id + ")", "deleteBBSEmail"); EmailSend email = new EmailSend(); for (int i = 0; i <= dsBBS.Tables["deleteBBSEmail"].Rows.Count - 1; i++) { try { } catch (Exception e) { email.send((string)dsBBS.Tables["deleteBBSEmail"].Rows[i]["UserEmail"].ToString(), body); } } DataSet ds = new DataSet(); string sql = ""; //sql = sql + "delete from TB_BBS where id in (" + id + ")"; //cn.mdb_exe(sql); //sql = "delete from TB_Message where BBSID in (" + id + ")"; //cn.mdb_exe(sql); sql = sql + "update TB_BBS set DeleSign=0 where id in (" + id + ")"; cn.mdb_exe(sql); //string[] arrayId = id.Split(','); //for (int i = 0; i < arrayId.Length; i++) //{ // cn.mdb_exe("insert into TB_BBSAdminIncident (BBSID,AdminID,Meno,EditTime,Types) values (" + arrayId[i] + "," + Request.Cookies["bbsadmin_id"].Value + ",'" + this.txtMeno.Text + "',getDate(),3)"); //} MessageBox("opsuccess", "恢复成功"); //清空delList delList.Text = ""; } else { //没有选择任何要删除的ID,弹出此对话框 MessageBox("opfail", "未选择任何要恢复的项目"); } }
public EventService() { this.broadcastEvent = new BroadcastMessageEvent(); this.notification = new Notification(); this.feedbackNotification = new FeedbackNotification(); this.feedbackNotifyEvent = new FeedbackNotifyEvent(); this.messageHub = new MessageHub(); this.messasgeEvent = new MessageEvent(); this.hrAvailableNotify = new HrAvailableNotify(); emailSend = new EmailSend(); }
public static void TestSend(EmailSend es, string title, string content) { if (es.Send(title, content)) { Console.WriteLine("发送成功"); } else { Console.WriteLine("发送失败"); } }
private async void WriteOrdersListToFileAndEmail() { var itemsToOrder = StackOfItemsToOrder.Children; int numItems = itemsToOrder.Count; string emailBody = ""; string emailHeading = "<Body style='margin:auto; background:darkgray; height:1000px; width:80%;'><h1 style='background:lightskyblue; Margin:auto; text-align:center'>Please Order the Following:</h1>"; string emailTailing = "</Body>"; for (int i = 0; i <= numItems - 1; i++) { if (((CustomItemToOrder)itemsToOrder[i]).CrossOrTick.Source.ToString() == @"pack://application:,,,/Images/GreenTick.png") { int count = i + 1;//This is a counter used in numbering the items to order within the email. emailBody = emailBody + CreateOrderString((CustomItemToOrder)itemsToOrder[i], ref count); } } emailBody = emailHeading + emailBody + emailTailing; string password = getUserPassword(); emailSendWindowReference = new EmailSend(); emailSendWindowReference.Show(); try { System.Threading.Tasks.Task task = System.Threading.Tasks.Task.Run(() => SendEmail(emailBody, password)); await task; IUpdateEmailProgress emailProgress = emailSendWindowReference; emailProgress.TickEmailComplete(); ClearOrderedItemsFromDbTable(); } catch (Exception e) { switch (e.HResult.ToString()) { case "-2146233088": emailSendWindowReference.emailStatusText.Content = "Sending failed. Did you enter your password in correctly?"; break; default: MessageBox.Show("Sending failed. Unknown Error Code Received: " + e.HResult.ToString()); break; } var image = new BitmapImage(); image.BeginInit(); image.UriSource = new Uri("/Images/RedCross.png", UriKind.Relative); image.EndInit(); ImageBehavior.SetAnimatedSource(emailSendWindowReference.emailSending, image); } }
/// <summary> /// SendEmail - method for sending email notification /// </summary> /// <param name="log"></param> private void SendEmail(string subject, string body) { EmailSend email = new EmailSend(); email.From = ""; email.To = ""; email.Subject = subject; email.Body = body; email.Port = 25; email.SMTPClient = ""; email.SendEmail(); }
protected void DetailsView1_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e) { GridView1.Visible = true; DetailsView1.Visible = false; string edit = Request.QueryString["edit"]; if (edit == "2") { EmailSend send = new EmailSend(); send.sendPwdEmail(); } }
private void EnviarEmail5Dia() { DateTime email5dias = DateTime.Today; email5dias = email5dias.AddDays(5); AzureBiblioteca db = new AzureBiblioteca(); List <tb_emprestimo> livro5dia = db.tb_emprestimo.Where(x => x.dt_devolucao == email5dias && x.bt_devolvido == false && x.tb_notificacao.bt_email5DIa == false).ToList(); if (livro5dia.Count != 0) { foreach (tb_emprestimo emprestimo in livro5dia) { if (emprestimo.tb_locatario_id_locatario != null) { Send(emprestimo.tb_locatario.ds_email, emprestimo.tb_locatario.nm_locatario); } else { tb_aluno_dados emailAluno = db.tb_aluno_dados.Where(x => x.tb_aluno_id_aluno == emprestimo.tb_turma_aluno_id_turma_aluno).ToList().Single(); Send(emailAluno.ds_email, emprestimo.tb_turma_aluno.tb_aluno.nm_aluno); } tb_notificacao alt = db.tb_notificacao.Where(x => x.id_notificacao == emprestimo.tb_notificacao_id_notificacao).ToList().Single(); alt.bt_email5DIa = true; db.SaveChanges(); } void Send(string email, string nome) { EmailDTO mail = new EmailDTO(); mail.Assunto = "FALTAM 5 DIAS PARA A DEVOULUÇÃO!"; mail.DestinatarioEmail = email; mail.DestinatarioNome = nome; mail.Mensagem = Resources.email2; mail.RemetenteSenha = "pbtadmin1234"; mail.RemetenteNome = "Biblioteca FREI"; mail.RemetenteEmail = "*****@*****.**"; EmailSend send = new EmailSend(); send.EnviarEmail(mail); } } else { return; } }
public ActionResult SendMessage(EmailSend send) { try { sendMail(send.Email, send.Body); db.EmailSends.Add(send); db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } }
/*Name of Function : <<sendErrorLog>> Author :<<Prasanna>> * Date of Creation <<04-03-2021>> * Purpose : <<sendErrorLog>> * Review Date :<<>> Reviewed By :<<>>*/ public bool sendErrorLogEmail(string controllername, string methodname, string exception, Uri url) { EmailSend emlSndngList = new EmailSend(); emlSndngList.Subject = "Error Log Created"; emlSndngList.Body = "<html><head></head><body><div class='container'><b style='color:#40bfbf;'>Controller Name:</b>" + controllername + "</div><br/><div><b style='color:#40bfbf;'>Method Name:" + methodname + "</b></div><br /><div><b style='color:#40bfbf;'>URL:" + url + "</b></div><div><b style='color:#40bfbf;'>Exception Details:" + exception + "</b></div></body></html>"; emlSndngList.FrmEmailId = ConfigurationManager.AppSettings["fromemail"]; emlSndngList.ToEmailId = ConfigurationManager.AppSettings["ErrorToEmail"]; if ((!string.IsNullOrEmpty(emlSndngList.FrmEmailId) && !string.IsNullOrEmpty(emlSndngList.FrmEmailId)) && (emlSndngList.FrmEmailId != "NULL" && emlSndngList.ToEmailId != "NULL")) { this.sendEmail(emlSndngList); } return(true); }
public void delete() { //删除信息 //要删除的纪录的ID,保存在delList隐藏控件内 string id = delList.Text; if (id!="") { data_conn cn = new data_conn(); string body = "尊敬的用户:<br/>"; body += "感谢您参与我们的论坛.<br/>"; body += "由于您在发布的帖子违反本论坛协议而被管理员删除.敬请谅解详情请见<a herf=\"www.100allin.com\">www.100allin.com</a><br/>"; body += "您在使用过程中,如有任何问题或建议,请随时联系傲赢网客户服务人员,我们将热忱为您服务。顺颂商祺!"; DataSet dsBBS = cn.mdb_ds("select UserEmail from TB_User,TB_BBS where TB_User.Userid=TB_BBS.Userid and TB_BBS.id in (" + id + ")", "deleteBBSEmail"); EmailSend email = new EmailSend(); for (int i = 0; i <= dsBBS.Tables["deleteBBSEmail"].Rows.Count - 1; i++) { try { } catch (Exception e) { email.send((string)dsBBS.Tables["deleteBBSEmail"].Rows[i]["UserEmail"].ToString(), body); } } DataSet ds = new DataSet(); string sql = ""; sql = sql + "delete from TB_Question where id in (" + id + ")"; cn.mdb_exe(sql); sql = "delete from TB_Question_Answer where QuestionID in (" + id + ")"; cn.mdb_exe(sql); sql = "delete from TB_Question_supplement where QuestionID in (" + id + ")"; cn.mdb_exe(sql); MessageBox("opsuccess", "删除成功"); //清空delList delList.Text = ""; } else { //没有选择任何要删除的ID,弹出此对话框 MessageBox("opfail", "未选择任何要删除的项目"); } }
private void event_worker_DoWork(object sender, DoWorkEventArgs e) { try { EmailSend mailSend = new EmailSend(); DetailGroupBUS dgBus = new DetailGroupBUS(); ContentSendEventBUS cseBus = new ContentSendEventBUS(); SendContentBUS scBus = new SendContentBUS(); EventBUS eventBUS = new EventBUS(); DataTable tblSendList = dgBus.getGroupListByEventList(); if (tblSendList.Rows.Count > 0) { List<SendMailDTO> sendList = mailSend.convetToSendMail(tblSendList); int totalCnt = sendList.Count; foreach (SendMailDTO sendItem in sendList) { int eventId = sendItem.eventId; DataTable dtContentSendEvent = cseBus.GetByEventId(eventId); if (dtContentSendEvent.Rows.Count > 0) { if (sendItem.countReceivedMail == 0 && sendItem.lastReceivedMail == "") // Gui lan dau { int id = int.Parse(dtContentSendEvent.Rows[0]["id"].ToString()); int contentId = int.Parse(dtContentSendEvent.Rows[0]["ContentId"].ToString()); int hourSend = int.Parse(dtContentSendEvent.Rows[0]["HourSend"].ToString()); DataTable dtSendContent = scBus.GetByID(contentId); subject = dtContentSendEvent.Rows[0]["Subject"].ToString(); body = dtContentSendEvent.Rows[0]["Body"].ToString(); bool sendRs = false; // Send normal. bool send = sendMail(sendRs, sendItem.port, sendItem.hostName, sendItem.userSmtp, sendItem.passSmtp, sendItem.mailFrom, sendItem.senderName, subject, body, sendItem.recieveName, sendItem.mailTo, 0, id); logs_info.Info("Status: " + send + ", sendRegisterId:" + sendRegisterId + ", MailTo: " + sendItem.mailTo + ", mailFrom: " + mailFrom + ", Name: " + sendItem.recieveName); // Update tblDetailGroup. DetailGroupDTO dgDto = new DetailGroupDTO(); dgDto.CustomerID = sendItem.customerId; dgDto.GroupID = sendItem.groupId; dgDto.CountReceivedMail = sendItem.countReceivedMail + 1; dgDto.LastReceivedMail = DateTime.Now; dgBus.tblDetailGroup_Update(dgDto); eventBUS.tblEventCustomer_Update(eventId, sendItem.customerId, sendItem.countReceivedMail + 1); logHistoryForSendEvent(id, sendItem.mailTo, mailFrom, sendItem.recieveName, send); } else if (sendItem.countReceivedMail < dtContentSendEvent.Rows.Count) { string strReceivedMail = sendItem.lastReceivedMail; DateTime lastReceivedMail = DateTime.Now; if (strReceivedMail != "") { lastReceivedMail = DateTime.Parse(strReceivedMail); } int hourSend = int.Parse(dtContentSendEvent.Rows[sendItem.countReceivedMail]["HourSend"].ToString()); DateTime currentTime = lastReceivedMail.AddHours(hourSend); TimeSpan time = currentTime - DateTime.Now; /*if (DateTime.Now.Year == currentTime.Year && DateTime.Now.Month == currentTime.Month && DateTime.Now.Day == currentTime.Day && DateTime.Now.Hour == currentTime.Hour && DateTime.Now.Minute == currentTime.Minute)*/ if (time.Days < 0 || time.Hours < 0 || time.Minutes < 0 || time.Seconds < 0) { int contentId = int.Parse(dtContentSendEvent.Rows[sendItem.countReceivedMail]["ContentId"].ToString()); //DataTable dtSendContent = scBus.GetByID(contentId); //if (dtSendContent.Rows.Count > 0) //{ // subject = dtSendContent.Rows[0]["Subject"].ToString(); // body = dtSendContent.Rows[0]["Body"].ToString(); //} subject = dtContentSendEvent.Select("hoursend=" + hourSend)[0]["Subject"].ToString(); body = dtContentSendEvent.Select("hoursend=" + hourSend)[0]["Body"].ToString(); int id = Convert.ToInt32(dtContentSendEvent.Select("hoursend=" + hourSend)[0]["id"] + ""); bool sendRs = false; // Send normal. bool send = sendMail(sendRs, sendItem.port, sendItem.hostName, sendItem.userSmtp, sendItem.passSmtp, sendItem.mailFrom, sendItem.senderName, subject, body, sendItem.recieveName, sendItem.mailTo, 0, id); logHistoryForSendEvent(id, sendItem.mailTo, mailFrom, sendItem.recieveName, send); logs_info.Info("Status: " + send + ", sendRegisterId:" + sendRegisterId + ", MailTo: " + sendItem.mailTo + ", mailFrom: " + mailFrom + ", Name: " + sendItem.recieveName); // Update tblDetailGroup. DetailGroupDTO dgDto = new DetailGroupDTO(); dgDto.CustomerID = sendItem.customerId; dgDto.GroupID = sendItem.groupId; dgDto.CountReceivedMail = sendItem.countReceivedMail + 1; dgDto.LastReceivedMail = DateTime.Now; dgBus.tblDetailGroup_Update(dgDto); eventBUS.tblEventCustomer_Update(eventId, sendItem.customerId, sendItem.countReceivedMail + 1); } } } }// End forEach. } } catch (Exception ex) { logs.Error("timer2_tick", ex); } }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { checkCount(); OrdersInfo order = new OrdersInfo(); long orderID =Convert.ToInt64(DateTime.Now.ToString("yyyyMMddhhmmss")); Response.Cookies["orderID"].Value = orderID.ToString(); Response.Cookies["orderID"].Expires = DateTime.Now.AddDays(1); AddressInfo address = Address.GetAddressByID(); //定单编号,用户,送货用户,地址,邮编,电话 order.OrderID = orderID; order.UserName = address.UserName; order.AddressName = address.AddressName; order.Address = address.Address; order.Post = address.Post; order.Telephone = address.Telephone; //省份,城市,送货方式,付款方式 order.Province = address.Province; order.City = address.City; order.SendType = address.SendType; order.PayType = address.PayType; //是否开发票,图书价格,送货费用,总价格,留言 order.EnableInvoice =Convert.ToBoolean(InvoiceList.SelectedValue); order.BookPrice = Convert.ToDecimal(Session["orderPrice"].ToString().Substring(1)); order.SendPrice = Convert.ToDecimal(sendPrice.Text.Substring(1)); order.SumPrice = Convert.ToDecimal(sumPrice.Text.Substring(1)); order.BalancePrice = Convert.ToDecimal(balancePay.Text); order.NeedPayPrice = Convert.ToDecimal(needBalancePay.Text); order.TgPrice = 0; order.IsTg = false; order.Message = messageTxt.Text; Orders.InsertOrders(order); Address.UpdateAddressBalance(order.BalancePrice); try { EmailSend es = new EmailSend(); es.sendOrderEmail(orderID.ToString(), sumPrice.Text.Substring(1)); } catch (Exception) { } finally { Response.Redirect("shoppingComplete.aspx"); } }
private void auto_worker_DoWork(object sender, DoWorkEventArgs e) { try { EmailSend mailSend = new EmailSend(); DataTable tableSend = sendBUS.GetByTime(DateTime.Now, 0); if (tableSend.Rows.Count > 0) { //lblStatus.Text = "Đang gửi mail...."; foreach (DataRow item in tableSend.Rows) { sendRegisterId = int.Parse(item["Id"].ToString()); sendContentId = int.Parse(item["SendContentId"].ToString()); configId = int.Parse(item["MailConfigID"].ToString()); groupId = int.Parse(item["GroupTo"].ToString()); SendType = int.Parse(item["SendType"].ToString()); accountId = int.Parse(item["AccountId"].ToString()); int SendRegisterId = int.Parse(item["Id"] + ""); //Lấy thông tin cấu hình mail gửi getConfigServer(configId); // Lấy nội dung mail //getMailContent(sendContentId); subject = item["Subject"].ToString(); body = item["Body"].ToString(); IList<MailToDTO> recipients = mailSend.GetMailTod(SendRegisterId, groupId, SendType); //IList<string> EmailS int cnt = 0; int totalCnt = recipients.Count; Parallel.ForEach(recipients.AsParallel(), new ParallelOptions { MaxDegreeOfParallelism = maxParallelEmails }, recipient => { bool send = false; //DataTable tblPartSend = psBus.GetByUserIdAndGroupId(accountId, groupId); // Send normal. send = sendMail(send, port, hostName, userSmtp, passSmtp, mailFrom, senderName, subject, body, recipient.Name, recipient.MailTo, sendRegisterId, 0); logs_info.Info("Status: " + send + ", sendRegisterId:" + sendRegisterId + ", MailTo: " + recipient.MailTo + ", mailFrom: " + mailFrom + ", Name: " + recipient.Name); // Write log for history send logHistoryForSend(sendRegisterId, recipient.MailTo, mailFrom, recipient.Name, send); lock (syncRoot) cnt++; }); //foreach (MailToDTO recipient in recipients) //{ // bool send = false; // //DataTable tblPartSend = psBus.GetByUserIdAndGroupId(accountId, groupId); // // Send normal. // send = sendMail(send, port, hostName, userSmtp, passSmtp, mailFrom, senderName, // subject, body, recipient.Name, recipient.MailTo, sendRegisterId, 0); // logs_info.Info("Status: " + send + ", sendRegisterId:" + sendRegisterId + ", MailTo: " + recipient.MailTo + ", mailFrom: " + mailFrom + ", Name: " + recipient.Name); // // Write log for history send // logHistoryForSend(sendRegisterId, recipient.MailTo, mailFrom, recipient.Name, send); //} // Update status for send mail campaign. sendBUS.tblSendRegister_UpdateStatus(sendRegisterId, 1, DateTime.Now); } //timer1.Start(); //lblStatus.Text = "Đang chờ gửi mail"; } } catch (Exception ex) { logs.Error("auto_worker_DoWork", ex); } }