// send user name and password to user personalized protected void OvationForGotPassword_SendingMail(object sender, MailMessageEventArgs e) { e.Cancel = true; MembershipUser lostinfoUer = Membership.GetUser(OvationForGotPassword.UserName); string lostinfoPW = lostinfoUer.GetPassword(); RFPmailclientToUse = new SmtpClient(); e.Message.From = new MailAddress("*****@*****.**", "Ovation and Lawyers Travel 2014 RFP"); e.Message.To.Add(new MailAddress(OvationForGotPassword.UserName, getmypersonalName(lostinfoUer.ToString()))); e.Message.Subject = "Ovation and Lawyers Travel 2014 RFP your login info"; e.Message.Priority = MailPriority.High; e.Message.IsBodyHtml = false; e.Message.Body = getmypersonalName(lostinfoUer.ToString()) + " here is your login information," + Environment.NewLine + Environment.NewLine + "User Name: " + lostinfoUer + Environment.NewLine + Environment.NewLine + "Password: "******"Go to http://dev.ovationtravel.com/OvationRFP/login.aspx"; // send the message RFPmailclientToUse.Send(e.Message); //and clean up resource RFPmailclientToUse.Dispose(); // show success message OvationForGotPassword.SuccessText = @"<div class=""errors"" style=""width:800px;margin-top:20px;""><p style=""margin-left:10px;"">" + getmypersonalName(lostinfoUer.ToString()) + " your information has been sent to the email address you registered with.</p></div>"; }
public static String RequestPassword(object sender, System.Web.UI.WebControls.MailMessageEventArgs e, String username, String sourcePage) { String message; String log_text = ""; username = HttpContext.Current.Server.HtmlEncode(username); try { System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com"); smtp.EnableSsl = true; smtp.Send(e.Message); message = "The login credentials for the specified username have been sent to the e-mail address associated with the account and should arrive shortly."; log_text = "Successfully Requested Password for username " + username; } catch (Exception r) { message = "Error requesting password for username " + username + ". Please try again!"; log_text = "Error requesting password for username " + username + Environment.NewLine + " " + r.Message + " " + r.StackTrace; } finally { Util.WriteLogWithDetails(log_text + " [Requested from " + sourcePage + "]", "requestpassword_log"); e.Cancel = true; } return(message); }
public void SendMail(MailMessageEventArgs e) { GetSmtpClient().Send(e.Message); //Since the message is sent here, set cancel=true so the original SmtpClient will not try to send the message too: e.Cancel = true; }
protected void PasswordRecovery1_SendingMail( object sender, MailMessageEventArgs e ) { // get the username and password from the body string body = e.Message.Body; // remove first line... body = body.Remove( 0, body.IndexOf( '\n' ) + 1 ); // remove "Username: "******": " ) + 2 ); // get first line which is the username string userName = body.Substring( 0, body.IndexOf( '\n' ) ); // delete that same line... body = body.Remove( 0, body.IndexOf( '\n' ) + 1 ); // remove the "Password: "******": " ) + 2 ); // the rest is the password... string password = body.Substring( 0, body.IndexOf( '\n' ) ); // get the e-mail ready from the real template. YafTemplateEmail passwordRetrieval = new YafTemplateEmail( "PASSWORDRETRIEVAL" ); string subject = String.Format( GetText( "PASSWORDRETRIEVAL_EMAIL_SUBJECT" ), PageContext.BoardSettings.Name ); passwordRetrieval.TemplateParams["{username}"] = userName; passwordRetrieval.TemplateParams["{password}"] = password; passwordRetrieval.TemplateParams["{forumname}"] = PageContext.BoardSettings.Name; passwordRetrieval.TemplateParams["{forumlink}"] = String.Format( "{0}", YafForumInfo.ForumURL ); passwordRetrieval.SendEmail( e.Message.To[0], subject, true ); // manually set to success... e.Cancel = true; PasswordRecovery1.TabIndex = 3; }
protected void RegisterUser_SendingMail(object sender, MailMessageEventArgs e) { var user = Membership.GetUser(RegisterUser.UserName); var url = Mailer.GetAbsoluteUrl(this.Request, "/Account/Verify.aspx?userid=" + user.ProviderUserKey.ToString()); e.Message.Body = e.Message.Body.Replace("<%VerifyUrl%>", url); }
protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e) { Library.SendMailFromPageToMember("*****@*****.**", Member.GetMemberFromLoginName(PasswordRecovery1.UserName), "your password", 1056); e.Cancel = true; }
public void DispatchEmail(object sender, MailMessageEventArgs e) { e.Message.Subject = "Nuevo Password Recovery"; MailMessage msg = e.Message; SmtpClient client = new SmtpClient(); client.EnableSsl = true; client.Send(msg); e.Cancel = true; }
/// <summary> /// Handles the SendingMail event of the prPasswordRecover control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.Web.UI.WebControls.MailMessageEventArgs"/> instance containing the event data.</param> protected void prPasswordRecover_SendingMail(object sender, MailMessageEventArgs e) { try { MessageService messageService = new MessageService(); messageService.Send(e.Message); e.Cancel = true; } catch(Exception ex) { Logger.Error("prPasswordRecover_SendingMail " + e.Message.To[0].Address , ex); } }
internal static void SendPasswordMail(string email, string userName, string password, MailDefinition mailDefinition, string defaultSubject, string defaultBody, OnSendingMailDelegate onSendingMailDelegate, OnSendMailErrorDelegate onSendMailErrorDelegate, Control owner) { // If the MailAddress ctor throws an exception, raise the error event but do not // rethrow the exception. We do not rethrow the exception since the email address // is user-entered data, and it should not cause an unhandled exception in the page. // If any other part of creating or sending the MailMessage throws an exception, // it is most likely a developer error so the exception should be rethrown. // (VSWhidbey 490984) try { new MailAddress(email); } catch (Exception e) { SendMailErrorEventArgs args = new SendMailErrorEventArgs(e); // SendMailErrorEventArgs.Handled should be true, to indicate that the exception // will not be rethrown. (VSWhidbey 529233) args.Handled = true; onSendMailErrorDelegate(args); return; } try { using (MailMessage message = CreateMailMessage(email, userName, password, mailDefinition, defaultBody, owner)) { if (mailDefinition.SubjectInternal == null && defaultSubject != null) { message.Subject = defaultSubject; } MailMessageEventArgs args = new MailMessageEventArgs(message); onSendingMailDelegate(args); if (args.Cancel) { return; } SmtpClient smtp = new SmtpClient(); smtp.Send(message); } } catch (Exception e) { SendMailErrorEventArgs args = new SendMailErrorEventArgs(e); onSendMailErrorDelegate(args); // If the error wasn't handled, we rethrow if (!args.Handled) { throw; } } }
protected void CreateUserWizard1_SendingMail(object sender, MailMessageEventArgs e) { Dictionary<string, string> values = new Dictionary<string, string>(2); values.Add("<%UserName%>", CreateUserWizard1.UserName); //values.Add("<%Password%>", CreateUserWizard1.Password); values.Add("<%email%>", CreateUserWizard1.Email); values.Add("<%id%>", Membership.GetUser(CreateUserWizard1.UserName).ProviderUserKey.ToString()); MailMessage msg = CreateUserWizard1.MailDefinition.CreateMailMessage( CreateUserWizard1.Email, values, CreateUserWizard1); e.Message.Body = msg.Body; }
protected void createUserWizard_SendingMail( object sender, MailMessageEventArgs e ) { e.Cancel = !this.createUserWizard.DisableCreatedUser; if ( this.createUserWizard.DisableCreatedUser ) { MembershipUser newUser = Membership.GetUser( this.createUserWizard.UserName ); Guid newUserId = ( Guid ) newUser.ProviderUserKey; string urlBase = Request.Url.GetLeftPart( UriPartial.Authority ) + Request.ApplicationPath; string verificationUrl = urlBase + "/verification.aspx?ID=" + newUserId.ToString( ); e.Message.Body = e.Message.Body .Replace( "<%VerificationUrl%>", verificationUrl ) .Replace( "<%AdminEmail%>", Settings.Default.AdminEmail ); } }
/// <summary> /// Handles the SendingMail event of the PasswordRecovery1 control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.MailMessageEventArgs"/> instance containing the event data.</param> protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e) { e.Cancel = true; MembershipUser user = Membership.GetUser(PasswordRecovery1.UserName); if (user != null) { Log.InfoFormat("User {0} requested a password reminder on {1}", user, DateTime.Now); ITUser.SendUserPasswordReminderNotification(user, PasswordRecovery1.Answer); } else { // This exception can expose a specialized type of brute force attack against the username. Log.Error("Hack Attempt! Password Reminder Bypass by '" + PasswordRecovery1.UserName + "'", new ArgumentException(String.Format("Non-Existent User '{0}' bypassed something in the password reminder\r\nAt {1} from IP Address {2}\r\nUser Agent {3}", PasswordRecovery1.UserName, DateTime.Now, Context.Request.UserHostAddress,Context.Request.UserAgent ))); } }
protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e) { try { MailMessage oMail = new MailMessage(); oMail.From = new MailAddress("*****@*****.**"); oMail.To.Add(new MailAddress(PasswordRecovery1.UserName)); SmtpClient client = new SmtpClient(); client.EnableSsl = true; client.Send(oMail); oMail = null; } catch (Exception) { throw; } }
internal static void SendPasswordMail(string email, string userName, string password, MailDefinition mailDefinition, string defaultSubject, string defaultBody, OnSendingMailDelegate onSendingMailDelegate, OnSendMailErrorDelegate onSendMailErrorDelegate, Control owner) { try { new MailAddress(email); } catch (Exception exception) { SendMailErrorEventArgs e = new SendMailErrorEventArgs(exception) { Handled = true }; onSendMailErrorDelegate(e); return; } try { using (MailMessage message = CreateMailMessage(email, userName, password, mailDefinition, defaultBody, owner)) { if ((mailDefinition.SubjectInternal == null) && (defaultSubject != null)) { message.Subject = defaultSubject; } MailMessageEventArgs args2 = new MailMessageEventArgs(message); onSendingMailDelegate(args2); if (!args2.Cancel) { new SmtpClient().Send(message); } } } catch (Exception exception2) { SendMailErrorEventArgs args3 = new SendMailErrorEventArgs(exception2); onSendMailErrorDelegate(args3); if (!args3.Handled) { throw; } } }
protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e) { //pnlContinue.Visible = true; //rBTNContinue.Visible = true; }
protected void createUser_SendingMail(object sender, MailMessageEventArgs e) { var message = e.Message.Body.Replace("{{ pwd }}", this.createUser.Password); e.Message.Body = message; }
void SendMail (string username, string password) { MembershipUser user = MembershipProviderInternal.GetUser (UserName, false); if (user == null) return; ListDictionary dictionary = new ListDictionary (); dictionary.Add ("<%USERNAME%>", username); dictionary.Add ("<%PASSWORD%>", password); MailMessage message = MailDefinition.CreateMailMessage (user.Email, dictionary, this); MailMessageEventArgs args = new MailMessageEventArgs (message); OnSendingMail (args); SmtpClient smtpClient = new SmtpClient (); try { smtpClient.Send (message); } catch (Exception e) { SendMailErrorEventArgs mailArgs = new SendMailErrorEventArgs (e); OnSendMailError (mailArgs); if (!mailArgs.Handled) throw e; } }
protected virtual void OnSendingMail (MailMessageEventArgs e) { if (Events != null) { MailMessageEventHandler eh = (MailMessageEventHandler) Events [SendingMailEvent]; if (eh != null) eh (this, e); } }
/// <summary> /// Overrides the built in mail sending and calls our mail sending function /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void _ctlPasswordRecovery_SendingMail(object sender, MailMessageEventArgs e) { e.Cancel = true; SendEmail(); }
protected virtual void OnSendingMail(MailMessageEventArgs e) { MailMessageEventHandler handler = (MailMessageEventHandler) base.Events[EventSendingMail]; if (handler != null) { handler(this, e); } }
protected void Passwordrecovery1_SendingMail(object sender, MailMessageEventArgs e) { }
/// <summary> /// Kludge to recover from Bug#189 The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e) { MailMessage mm = new MailMessage(); mm.IsBodyHtml = true; mm.From = e.Message.From; mm.Subject = e.Message.Subject.ToString(); mm.To.Add(e.Message.To[0]); mm.Body = e.Message.Body; SmtpClient smtp = new SmtpClient(); smtp.EnableSsl = true; smtp.Send(mm); e.Cancel = true; }
protected void RecoverSendingMail(object sender, MailMessageEventArgs e) { string memberIP = Common.GetIP4Address(); e.Message.Body = e.Message.Body.Replace("[IPAddress]", memberIP).Replace("[forumTitle]", Config.ForumTitle); }
void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e) { e.Message.Body = e.Message.Body.Replace("{SiteName}", siteSettings.SiteName); e.Message.Body = e.Message.Body.Replace("{SiteLink}", SiteUtils.GetNavigationSiteRoot()); if (WebConfigSettings.DisableDotNetOpenMail) { SmtpSettings smtpSettings = SiteUtils.GetSmtpSettings(); Email.SetMessageEncoding(smtpSettings, e.Message); if (siteSettings.DefaultFromEmailAlias.Length > 0) { e.Message.From = new System.Net.Mail.MailAddress(siteSettings.DefaultEmailFromAddress, siteSettings.DefaultFromEmailAlias); } else { e.Message.From = new System.Net.Mail.MailAddress(siteSettings.DefaultEmailFromAddress); } Email.Send(smtpSettings, e.Message); e.Cancel = true; //stop here so the "built-in" mail routine doesn't run } }
protected virtual new void OnSendingMail(MailMessageEventArgs e) { }
protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e) { e.Cancel = true; }
public static void w_SendingMail (object sender, MailMessageEventArgs e) { if (e.Message.Body.IndexOf ("123") > 0) WebTest.CurrentTest.UserData = "w_SendingMail"; }
protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e) { PasswordRecovery passRec = (PasswordRecovery)loginViewIndex.FindControl("PasswordRecovery1"); passRec.Visible = false; }
protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e) { Label1.Visible = true; }
protected void PasswordRecovery1_SendingMail( object sender, MailMessageEventArgs e) { SmtpClient sc = new SmtpClient(); sc.Send(e.Message); }
void SendPasswordByMail (string username, string password) { MembershipUser user = MembershipProviderInternal.GetUser (UserName, false); if (user == null) return; // DO NOT change format of the message - it has to be exactly the same as in // .NET as some software (e.g. YetAnotherForum) depends on it. string messageText = "Please return to the site and log in using the following information.\n" + "User Name: <%USERNAME%>\nPassword: <%PASSWORD%>\n"; ListDictionary dictionary = new ListDictionary (StringComparer.OrdinalIgnoreCase); dictionary.Add ("<%USERNAME%>", username); dictionary.Add ("<% UserName %>", username); dictionary.Add ("<%PASSWORD%>", password); dictionary.Add ("<% Password %>", password); MailMessage message = null; if (MailDefinition.BodyFileName.Length == 0) message = MailDefinition.CreateMailMessage (user.Email, dictionary, messageText, this); else message = MailDefinition.CreateMailMessage (user.Email, dictionary, this); if (string.IsNullOrEmpty (message.Subject)) message.Subject = "Password"; MailMessageEventArgs args = new MailMessageEventArgs (message); OnSendingMail (args); SmtpClient smtpClient = new SmtpClient (); try { smtpClient.Send (message); } catch (Exception e) { SendMailErrorEventArgs mailArgs = new SendMailErrorEventArgs (e); OnSendMailError (mailArgs); if (!mailArgs.Handled) throw e; } }
void SendPasswordByMail (MembershipUser user, string password) { if (user == null) return; if (_mailDefinition == null) return; string messageText = "A new account has been created for you. Please go to the site and log in using the following information.\nUser Name: <%USERNAME%>\nPassword: <%PASSWORD%>"; ListDictionary dictionary = new ListDictionary (); dictionary.Add ("<%USERNAME%>", user.UserName); dictionary.Add ("<%PASSWORD%>", password); MailMessage message = null; if (MailDefinition.BodyFileName.Length == 0) message = MailDefinition.CreateMailMessage (user.Email, dictionary, messageText, this); else message = MailDefinition.CreateMailMessage (user.Email, dictionary, this); if (string.IsNullOrEmpty (message.Subject)) message.Subject = "Account information"; MailMessageEventArgs args = new MailMessageEventArgs (message); OnSendingMail (args); SmtpClient smtpClient = new SmtpClient (); try { smtpClient.Send (message); } catch (Exception e) { SendMailErrorEventArgs mailArgs = new SendMailErrorEventArgs (e); OnSendMailError (mailArgs); if (!mailArgs.Handled) throw e; } }
protected virtual void OnSendingMail (MailMessageEventArgs e) { MailMessageEventHandler eh = events [sendingMailEvent] as MailMessageEventHandler; if (eh != null) eh (this, e); }