How to get the CreateUserWizard to email using the DisplayName instead of From email address?


I'm trying to work out how to get the CreateUserWizard to email using the DisplayName (or equivalent) so that the recipient sees a name (e.g. Ben Miller) instead of an email address in the From field of their email client.  In my CreateUserWizard control I have tried putting a name (e.g Ben Miller) in like this:

    <MailDefinition BodyFileName="~/BodyFile.txt"
            Subject="Welcome new User" From=", Ben Miller">

I have also tried using the web.config file, but neither of these seem to use the DisplayName

      <smtp from=", Ben Miller">
        <network host="" password="plugh" userName=""/>

In the .NET Framework Class Library doco I have found MailAddress, however I can't get this style of email to work with the MailDefinition

MailAddress Class
The MailAddress class is used by the SmtpClient and MailMessage classes to store address information for e-mail messages.

A mail address is composed of a User name, Host name and optionally, a DisplayName. The DisplayName can contain non-ASCII characters if you encode them.

MailAddress..::.DisplayName Property
Display names that contain non-ASCII characters are returned in human-readable form. Use the ToString method to get the encoded form of the DisplayName.

Some software programs that are used to read e-mail display the DisplayName property value instead of, or in addition to, the e-mail address.

and it gives an example like this:

MailAddress from = new MailAddress("", "Ben Miller");

Anyone got an idea how to get this working with the CreateUserWizard?

8/6/2008 12:49:35 PM 27051 articles. 1 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 39
Get it on Google Play
Get it on Apple App Store

You can hook into the SendingMail event of the wizard

Protected Sub PasswordRecovery1_SendingMail(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MailMessageEventArgs) Handles PasswordRecovery1.SendingMail
        Dim s As String = e.Message.Body.Trim
        'create a new mail here and send it

e.Cancel = true   'cancel the wizard's mail
End Sub


Dont forget to click "Mark as Answer" on the post that helped you.
8/6/2008 2:25:16 PM

 Thanks Prashant, not the easy answer I was hoping for, but at least you've cleared this up for me.

9/5/2008 12:47:33 PM