public virtual ActionResult SubmitFeedback(string name, string email, string feedback, string fromUrl) { feedback = HttpUtility.HtmlDecode(feedback); string emailBody = string.Format( @"The following feedback was submitted: Name: {0} Email: {1} URL: {2} Date: {3} Feedback: {4}", name, email, fromUrl, DateTime.Now.ToString(), feedback); EmailUtils emailUtil = new EmailUtils(); emailUtil.Send("*****@*****.**", "Feedback Submitted", emailBody); return(View()); }
public virtual ActionResult SubmitFeedback(string name, string email, string feedback, string fromUrl) { feedback = HttpUtility.HtmlDecode(feedback); string emailBody = string.Format( @"The following feedback was submitted: Name: {0} Email: {1} URL: {2} Date: {3} Feedback: {4}", name, email, fromUrl, DateTime.Now.ToString(), feedback); EmailUtils emailUtil = new EmailUtils(); emailUtil.Send("*****@*****.**", "Feedback Submitted", emailBody); return View(); }
public ActionResult Compose(ComposeMail newMessage) { if (Request["Send"] != null) { if (ModelState.IsValid) { // actually send it this time try { EmailUtils.Send(newMessage.MailMessage); } catch { // there was an error sending the message throw new HttpException(500, Support.Error_Sending); } try { if (!string.IsNullOrEmpty(newMessage.Uid)) { using (var imap = EnsureConnection()) { imap.SelectMailbox("Sent Items"); imap.AppendMail(newMessage.MailMessage); imap.SelectMailbox("Drafts"); imap.DeleteMessage(newMessage.Uid); } } } catch { throw new HttpException(417, Support.Error_Copying); } return(new EmptyResult()); } else { Response.StatusCode = 417; Response.TrySkipIisCustomErrors = true; return(PartialView(newMessage)); } } else { newMessage.Uid = Draft(newMessage.MailMessage, newMessage.Uid).Uid; return(Json(newMessage)); } }
private void SendRegistrationEmail(string emailAddress, string firstName, string lastName, string key) { var emailModel = new KeyedEmailModel { EmailAddress = emailAddress, FirstName = firstName, LastName = lastName, Key = key }; var message = ControllerContext.Render("_AddEmailPartial", new ViewDataDictionary(emailModel)).ToString(); EmailUtils.Send(message, emailAddress, firstName, lastName, subject: ControllerRes.Account.Email_SubjectUserRegistration); }
public void monitorUrl() { String result = HttpUtils.postRequest(url, "", null); if ("success".Equals(result)) { button.BackColor = Color.LimeGreen; } else { button.BackColor = Color.OrangeRed; if (!"".Equals(warn)) { String[] warnArray = warn.Split(";"); for (int index = 0; index < warnArray.Length; index++) { String warnSingle = warnArray[index]; if (warnSingle.Contains("qyapi.weixin.qq.com")) { try { // 企业微信机器人地址 WorkWxSendMessage workWxSendMessage = new WorkWxSendMessage(); workWxSendMessage.msgtype = WorkWxSendMessage.MSGTYPE_TEXT; WorkWxSendMessage.Text text = new WorkWxSendMessage.Text(); text.content = title + "服务异常!"; workWxSendMessage.text = text; String robotSendContentJson = JsonConvert.SerializeObject(workWxSendMessage); LogUtils.writeLog(robotSendContentJson); HttpUtils.postRequest(warn, robotSendContentJson, HttpUtils.CONTENT_TYPE_APPLICATION_JSON); } catch (Exception e) { LogUtils.writeLog(e.StackTrace); } } else if (warnSingle.Contains("@163.com") || warnSingle.Contains("@qq.com") || warnSingle.Contains("@163.com")) { // 邮箱 String emailBody = title + "服务无法访问!"; EmailUtils emailUtis = new EmailUtils(Config.emailServer, warnSingle, Config.fromEmail, "服务监控", emailBody, Config.username, Config.password, Config.emailPort, true, true); emailUtis.Send(); } else { } } } } }
/// <summary> /// Generates the e-mail using the extension method ControllerContext.Render() /// </summary> /// <param name="emailAddress">The e-mail address to send the reset email to.</param> /// <param name="key">The unique secret key sent only to that e-mail address that verifies it reached the right person and they can reset their account.</param> /// <param name="firstName">First name of the user.</param> /// <param name="lastName">Last name of the user.</param> private void SendResetEmail(string emailAddress, string key, string firstName = null, string lastName = null) { // Send email for password reset completion. var emailModel = new KeyedEmailModel { EmailAddress = emailAddress, FirstName = firstName, LastName = lastName, Key = key }; var message = ControllerContext.Render("_ResetEmailPartial", new ViewDataDictionary(emailModel)).ToString(); EmailUtils.Send(message, emailAddress, firstName, lastName, subject: Account.Email_SubjectPasswordReset); }
public override void Notify() { string emailTo = ConfigurationSettings.AppSettings["emailTo"]; string emailFrom = ConfigurationSettings.AppSettings["emailFrom"]; string subject = ConfigurationSettings.AppSettings["subject"]; string pass = _checkResult.Success ? "Successful" : "Failure"; if (string.IsNullOrEmpty(subject)) { subject = _ctx.Definition.Name + " Version Check " + pass; } string emailEnabled = ConfigurationSettings.AppSettings["enableEmails"].ToLower().Trim(); bool enableEmails = Convert.ToBoolean(emailEnabled); // Override from command line. if (_commandLineArgs.Length >= 2) { emailTo = _parsedArgs.NamedArgs["email"]; } string failuresOnly = ConfigurationSettings.AppSettings["enableEmailsOnlyOnFailures"].ToLower().Trim(); bool enableEmailOnlyOnFailure = Convert.ToBoolean(failuresOnly); if (enableEmails && !enableEmailOnlyOnFailure || enableEmails && enableEmailOnlyOnFailure && !_checkResult.Success) { string message = string.Format("Version Check {0} for {1}", pass, _ctx.Definition.Name); if (!_checkResult.Success) { message += Environment.NewLine + _checkResult.Message; message += Environment.NewLine + GetCheckFailuresText(); } else { message += Environment.NewLine + BuildDisplay(false, null); } EmailUtils.Send(emailTo, emailFrom, subject, message); } }