|
85 | 85 |
|
86 | 86 | <a name="sending_email_messages"></a>
|
87 | 87 | ## Sending Email Messages
|
88 |
| - The <xref:System.Web.UI.WebControls.ChangePassword> control can be configured to use email services to send the new password to the user. To send email messages to users from any of ASP.NET Web server controls, you must configure an email server in the Web.config file for your application. For more information, see [NIB: How to: Install and Configure SMTP Virtual Servers in IIS 6.0](https://msdn.microsoft.com/library/ed204b58-24af-47d0-9687-60e5df5f17f8). |
| 88 | + The <xref:System.Web.UI.WebControls.ChangePassword> control can be configured to use email services to send the new password to the user. To send email messages to users from any of ASP.NET Web server controls, you must configure an email server in the Web.config file for your application. For more information, see [How to: Install and Configure SMTP Virtual Servers in IIS 6.0](https://docs.microsoft.com/previous-versions/aspnet/8b83ac7t(v=vs.100)). |
89 | 89 |
|
90 | 90 | Email messages are configured using the <xref:System.Web.UI.WebControls.MailDefinition> class. You must set the <xref:System.Web.UI.WebControls.MailDefinition.BodyFileName%2A> property to instruct ASP.NET to send email.
|
91 | 91 |
|
|
2841 | 2841 | ## Examples
|
2842 | 2842 | The following code example shows how to use the <xref:System.Web.UI.WebControls.ChangePassword.MailDefinition%2A> property to define an email message that is sent to users who change their passwords. It assumes that there is a file called `MailFile.txt` that contains the text of the email message to send.
|
2843 | 2843 |
|
2844 |
| - To be able to send email messages to users, you must configure an email server in the Web.config file for your application. For more information, see [NIB: How to: Install and Configure SMTP Virtual Servers in IIS 6.0](https://msdn.microsoft.com/library/ed204b58-24af-47d0-9687-60e5df5f17f8). |
| 2844 | + To be able to send email messages to users, you must configure an email server in the Web.config file for your application. For more information, see [How to: Install and Configure SMTP Virtual Servers in IIS 6.0](https://docs.microsoft.com/previous-versions/aspnet/8b83ac7t(v=vs.100)). |
2845 | 2845 |
|
2846 | 2846 | [!code-aspx-csharp[ChangePasswordMailDefinition#1](~/samples/snippets/csharp/VS_Snippets_WebNet/ChangePasswordMailDefinition/CS/changepasswordmaildefinitioncs.aspx#1)]
|
2847 | 2847 | [!code-aspx-vb[ChangePasswordMailDefinition#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/ChangePasswordMailDefinition/VB/changepasswordmaildefinitionvb.aspx#1)]
|
|
3614 | 3614 | ## Examples
|
3615 | 3615 | The following code example demonstrates an ASP.NET page that uses a <xref:System.Web.UI.WebControls.ChangePassword> Web control, and includes an event handler for the <xref:System.Web.UI.WebControls.ChangePassword.SendingMail> event named `SendingMail`. The code example assumes that the ASP.NET Web site has been configured to use ASP.NET membership and Forms authentication, and that a user has been created whose name and password are known to you. For more information, see [How to: Implement Simple Forms Authentication](https://msdn.microsoft.com/library/9522bc8d-1a41-480a-aa11-c389a4ac2d2e).
|
3616 | 3616 |
|
3617 |
| - If the password change succeeds, the code attempts to use SMTP to send an email message to the user to confirm the change. This is done in the`SendingMail` event handler. For information about how to configure an SMTP server, see [NIB: How to: Install and Configure SMTP Virtual Servers in IIS 6.0](https://msdn.microsoft.com/library/ed204b58-24af-47d0-9687-60e5df5f17f8). For the purposes of this example, it is not necessary to configure an SMTP server; the example is constructed to test for a failure to send an email message. |
| 3617 | + If the password change succeeds, the code attempts to use SMTP to send an email message to the user to confirm the change. This is done in the`SendingMail` event handler. For information about how to configure an SMTP server, see [How to: Install and Configure SMTP Virtual Servers in IIS 6.0](https://docs.microsoft.com/previous-versions/aspnet/8b83ac7t(v=vs.100)). For the purposes of this example, it is not necessary to configure an SMTP server; the example is constructed to test for a failure to send an email message. |
3618 | 3618 |
|
3619 | 3619 | If a mail server is not configured correctly or some other error occurs and the email message cannot be sent, the `SendMailError` function is called. A message is displayed to the user. In addition, an event is logged to the Windows Application event log with the assumption that an event source named MySamplesSite already exists. See the code example below to create the specified event source. For more information about creating an event source, see [Server Event Handling in ASP.NET Web Forms Pages](https://msdn.microsoft.com/library/765bfc89-33ee-4d0d-bbe6-3b172c06def9). The <xref:System.Web.UI.WebControls.SendMailErrorEventArgs.Handled%2A> property of the <xref:System.Web.UI.WebControls.SendMailErrorEventArgs> object is set to `true` to indicate that the error has been handled.
|
3620 | 3620 |
|
|
3717 | 3717 | ## Examples
|
3718 | 3718 | The following code example demonstrates an ASP.NET page that uses a <xref:System.Web.UI.WebControls.ChangePassword> Web control, and includes an event handler for the <xref:System.Web.UI.WebControls.ChangePassword.SendingMail> event named `SendingMail`. The code example assumes that the ASP.NET Web site has been configured to use ASP.NET membership and Forms authentication, and that a user has been created whose name and password are known to you. For more information, see [How to: Implement Simple Forms Authentication](https://msdn.microsoft.com/library/9522bc8d-1a41-480a-aa11-c389a4ac2d2e).
|
3719 | 3719 |
|
3720 |
| - If the password change succeeds, the code attempts to use SMTP to send an email message to the user to confirm the change. This is done in the`SendingMail` event handler. For information about how to configure an SMTP server, see [NIB: How to: Install and Configure SMTP Virtual Servers in IIS 6.0](https://msdn.microsoft.com/library/ed204b58-24af-47d0-9687-60e5df5f17f8). For the purposes of this example, it is not necessary to configure an SMTP server; the example is constructed to test for a failure to send an email message. |
| 3720 | + If the password change succeeds, the code attempts to use SMTP to send an email message to the user to confirm the change. This is done in the`SendingMail` event handler. For information about how to configure an SMTP server, see [How to: Install and Configure SMTP Virtual Servers in IIS 6.0](https://docs.microsoft.com/previous-versions/aspnet/8b83ac7t(v=vs.100)). For the purposes of this example, it is not necessary to configure an SMTP server; the example is constructed to test for a failure to send an email message. |
3721 | 3721 |
|
3722 | 3722 | If a mail server is not configured correctly or some other error occurs and the email message cannot be sent, the `SendMailError` function is called. A message is displayed to the user. In addition, an event is logged to the Windows Application event log with the assumption that an event source named MySamplesSite already exists. See the code example below to create the specified event source. For more information about creating an event source, see [Server Event Handling in ASP.NET Web Forms Pages](https://msdn.microsoft.com/library/765bfc89-33ee-4d0d-bbe6-3b172c06def9). The <xref:System.Web.UI.WebControls.SendMailErrorEventArgs.Handled%2A> property of the <xref:System.Web.UI.WebControls.SendMailErrorEventArgs> object is set to `true` to indicate that the error has been handled.
|
3723 | 3723 |
|
|
4300 | 4300 |
|
4301 | 4301 | The code example assumes that the ASP.NET Web site has been configured to use ASP.NET membership and Forms authentication, and that a user has been created whose name and password are known to you. For more information, see [How to: Implement Simple Forms Authentication](https://msdn.microsoft.com/library/9522bc8d-1a41-480a-aa11-c389a4ac2d2e).
|
4302 | 4302 |
|
4303 |
| - If the password change succeeds, the code attempts to use SMTP to send an email message to the user to confirm the change. This is done in the`SendingMail` event handler. For information about how to configure an SMTP server, see [NIB: How to: Install and Configure SMTP Virtual Servers in IIS 6.0](https://msdn.microsoft.com/library/ed204b58-24af-47d0-9687-60e5df5f17f8). For the purposes of this example, it is not necessary to configure an SMTP server; the example is constructed to test for a failure to send an email message. |
| 4303 | + If the password change succeeds, the code attempts to use SMTP to send an email message to the user to confirm the change. This is done in the`SendingMail` event handler. For information about how to configure an SMTP server, see [How to: Install and Configure SMTP Virtual Servers in IIS 6.0](https://docs.microsoft.com/previous-versions/aspnet/8b83ac7t(v=vs.100)). For the purposes of this example, it is not necessary to configure an SMTP server; the example is constructed to test for a failure to send an email message. |
4304 | 4304 |
|
4305 | 4305 | If a mail server is not configured correctly or some other error occurs and the email message cannot be sent, the `SendMailError` function is called. A message is displayed to the user. In addition, an event is logged to the Windows Application event log with the assumption that an event source named MySamplesSite already exists. See the code example below to create the specified event source. For more information about creating an event source, see [Server Event Handling in ASP.NET Web Forms Pages](https://msdn.microsoft.com/library/765bfc89-33ee-4d0d-bbe6-3b172c06def9). The <xref:System.Web.UI.WebControls.SendMailErrorEventArgs.Handled%2A> property of the <xref:System.Web.UI.WebControls.SendMailErrorEventArgs> object is set to `true` to indicate that the error has been handled.
|
4306 | 4306 |
|
|
4392 | 4392 | ## Examples
|
4393 | 4393 | The following code example demonstrates an ASP.NET page that uses a <xref:System.Web.UI.WebControls.ChangePassword> Web control, and includes an event handler for the <xref:System.Web.UI.WebControls.ChangePassword.SendingMail> event named `SendingMail`. The code example assumes that the ASP.NET Web site has been configured to use ASP.NET membership and Forms authentication, and that a user has been created whose name and password are known to you. For more information, see [How to: Implement Simple Forms Authentication](https://msdn.microsoft.com/library/9522bc8d-1a41-480a-aa11-c389a4ac2d2e).
|
4394 | 4394 |
|
4395 |
| - If the password change succeeds, the code attempts to use SMTP to send an email message to the user to confirm the change. This is done in the`SendingMail` event handler. For information about how to configure an SMTP server, see [NIB: How to: Install and Configure SMTP Virtual Servers in IIS 6.0](https://msdn.microsoft.com/library/ed204b58-24af-47d0-9687-60e5df5f17f8). For the purposes of this example, it is not necessary to configure an SMTP server; the example is constructed to test for a failure to send an email message. |
| 4395 | + If the password change succeeds, the code attempts to use SMTP to send an email message to the user to confirm the change. This is done in the`SendingMail` event handler. For information about how to configure an SMTP server, see [How to: Install and Configure SMTP Virtual Servers in IIS 6.0](https://docs.microsoft.com/previous-versions/aspnet/8b83ac7t(v=vs.100)). For the purposes of this example, it is not necessary to configure an SMTP server; the example is constructed to test for a failure to send an email message. |
4396 | 4396 |
|
4397 | 4397 | If a mail server is not configured correctly or some other error occurs and the email message cannot be sent, the `SendMailError` function is called. A message is displayed to the user. In addition, an event is logged to the Windows Application event log with the assumption that an event source named MySamplesSite already exists. See the code example below to create the specified event source. For more information about creating an event source, see [Server Event Handling in ASP.NET Web Forms Pages](https://msdn.microsoft.com/library/765bfc89-33ee-4d0d-bbe6-3b172c06def9). The <xref:System.Web.UI.WebControls.SendMailErrorEventArgs.Handled%2A> property of the <xref:System.Web.UI.WebControls.SendMailErrorEventArgs> object is set to `true` to indicate that the error has been handled.
|
4398 | 4398 |
|
|
5024 | 5024 | ## Examples
|
5025 | 5025 | The following code example demonstrates an ASP.NET page that uses a <xref:System.Web.UI.WebControls.ChangePassword> Web control, and includes an event handler for the <xref:System.Web.UI.WebControls.ChangePassword.SendingMail> event named `SendingMail`. The code example assumes that the ASP.NET Web site has been configured to use ASP.NET membership and Forms authentication, and that a user has been created whose name and password are known to you. For more information, see [How to: Implement Simple Forms Authentication](https://msdn.microsoft.com/library/9522bc8d-1a41-480a-aa11-c389a4ac2d2e).
|
5026 | 5026 |
|
5027 |
| - If the password change succeeds, the code attempts to use SMTP to send an email message to the user to confirm the change. This is done in the`SendingMail` event handler. For information about how to configure an SMTP server, see [NIB: How to: Install and Configure SMTP Virtual Servers in IIS 6.0](https://msdn.microsoft.com/library/ed204b58-24af-47d0-9687-60e5df5f17f8). For the purposes of this example, it is not necessary to configure an SMTP server; the example is constructed to test for a failure to send an email message. |
| 5027 | + If the password change succeeds, the code attempts to use SMTP to send an email message to the user to confirm the change. This is done in the`SendingMail` event handler. For information about how to configure an SMTP server, see [How to: Install and Configure SMTP Virtual Servers in IIS 6.0](https://docs.microsoft.com/previous-versions/aspnet/8b83ac7t(v=vs.100)). For the purposes of this example, it is not necessary to configure an SMTP server; the example is constructed to test for a failure to send an email message. |
5028 | 5028 |
|
5029 | 5029 | If a mail server is not configured correctly or some other error occurs and the email message cannot be sent, the `SendMailError` function is called. A message is displayed to the user. In addition, an event is logged to the Windows Application event log with the assumption that an event source named MySamplesSite already exists. See the code example below to create the specified event source. For more information about creating an event source, see [Server Event Handling in ASP.NET Web Forms Pages](https://msdn.microsoft.com/library/765bfc89-33ee-4d0d-bbe6-3b172c06def9). The <xref:System.Web.UI.WebControls.SendMailErrorEventArgs.Handled%2A> property of the <xref:System.Web.UI.WebControls.SendMailErrorEventArgs> object is set to `true` to indicate that the error has been handled.
|
5030 | 5030 |
|
|
0 commit comments