tags:

views:

35

answers:

2

I use SmtpMail for users to forward site content. The user fills out a form which includes first name and email.

The email sent has the full email address as the "From address" in the recipients inbox (they see From: [email protected] while I want them to see From: Joe).

How can I format the "From address" to be the users inputted first name?

Thanks!

+2  A: 

The MailAddress class has an optional parameter where you can specify a display name. I assume it will be used when present.

Dim from As MailAddress = New MailAddress("[email protected]", "Ben Miller")
Dim to As MailAddress = New MailAddress("[email protected]", "Jane Clayton")
Dim message As MailMessage = New MailMessage(from, to)
lincolnk
This is causing the page not to load... any ideas?
Joe
@Joe ummmm.... no. maybe post the code you're having issue with?
lincolnk
Below is the code section that passes the main mail variables. "receiver, emailer, nombre" are the 3 variables pulled from the form. I need "nombre" to be passed through the mailer.from field instead of emailer. <code>mailer.To = receivermailer.Bcc = "[email protected]"mailer.From = emailermailer.BodyFormat = MailFormat.Htmlmailer.Subject = "Subject Line Here"</code>
Joe
+1  A: 

This has always worked for me:

    Dim myMessage As New MailMessage

    Dim myFrom As MailAddress = New MailAddress("[email protected]", "Bob Denver")
    Dim myTo As MailAddress = New MailAddress("[email protected]", "Steve Miller")

    myMessage.From = myFrom
    myMessage.To.Add(myTo)
knslyr