EmbeddedMailObject.EmbeddedMailObject(String, String) Constructor

Initializes a new instance of the EmbeddedMailObject class, using the specified identifier name and path to populate the object.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public:
EmbeddedMailObject (
	String^ name, 
	String^ path
)
public EmbeddedMailObject (
	String name, 
	String path
)
public function EmbeddedMailObject (
	name : String, 
	path : String
)
Not applicable.

Parameters

name

The name used as the identifier of the item to embed in the mail message. For more information, see Name.

path

The path used to retrieve an item to embed in the mail message. For more information, see Path.

The following code example shows a code-behind example of an ASP.NET page that uses a ChangePassword control, and includes an event handler for the SendingMail event named SendingMail. This 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.

If the password change succeeds, the code in the SendingMail event handler attempts to send an e-mail message to the user to confirm the change. SMTP must already be configured on the server in order for this code example to work. For information about how to configure an SMTP server, see How to: Configure an SMTP Virtual Server. 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 e-mail message.

If a mail server is not configured correctly or some other error occurs and the e-mail 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 Pages. The Handled property of the SendMailErrorEventArgs object is set to true to indicate that the error has been handled.

The following code example demonstrates using an .aspx page.

No code example is currently available or this language may not be supported.

The following code example demonstrates using a code-behind file.

No code example is currently available or this language may not be supported.

Use the following code example if you need to programmatically add the event source named MySamplesSite to your Application log. This event source must exist in order for the first code example to work correctly. The following code example requires Administrator privileges.

No code example is currently available or this language may not be supported.

The following example code can be used as the ChangePasswordMail.htm file for the preceding example code.

Security noteSecurity Note:

Sending user account names or passwords in an e-mail message is a potential security threat. E-mail messages are typically sent in plain text and can be read by special network "sniffing" applications. To improve security, use the mitigations that are described in Securing Login Controls.

<html>
<head><title></title></head>
<body>
<form>

  <h1>Your password for the account named &quot;<%Username%>&quot; has changed.</h1>

  <p>
  If you did not initiate this change, please call 1-206-555-0100.
  </p>
  
  <p>
  <a href="http://www.contoso.com/login.aspx">
    <img src="cid:LoginGif" alt="Log In" />
  </a> 
  </p>
  
  <p>
  Please read our attached Privacy Notice.
  </p>

</form>
</body>
</html>

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show: