Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing the "From" name.

Status
Not open for further replies.

nondrinker

Programmer
Jan 23, 2002
53
US
Hello,

I am trying to send out an email where the receiver should see a person's name in the from part instead of the email address. This is the code i currently have.

Something like:



Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.configuration")
Set Flds = iConf.Fields
With iMsg
Set .Configuration = iConf
.To = strTo
.CC = strCC
.FROM = strFrom
.Subject = strSubject
.TextBody = strMessage
.Send
End With


In the strFrom variable, if i try to send the email out by using something like: <Person Name> name@name.com then
the system gives an error. Currently the email goes out only if use name@name.com format only.

Any ideas as to how can i send the message out so that to the receiver it should look like as if it came from "Person Name" instead of "name@name.com". If the email address is also showing thats fine too, but i am just trying to add the "Person Name" part in the From part of the message.

Thank you.



 
I just checked in both Outlook & OE, and the 'from' disply shows only the name of the sender. One can right click the sender and obtain the email info.

This might be mail client specific.

What email client is giving you this behaviour?

rvnguy
"I know everything..I just can't remember it all
 
CDO CDONTS are very basic mail scripting solutions. As far as I know you cannot set the name property. You would have to use a 3rd party pop3 sender which includes setting this property in the dll library.

You might try AspSmartMail. I use it al;l the time, and it's free. Works a treat for what you want.

Here's the code I use:
Code:
	Dim mySmartMail
	Set mySmartMail = Server.CreateObject("aspSmartMail.SmartMail")

'	Mail Server
'	***********
	mySmartMail.Server = "123.213.132.231"
	
	If (Request("name") <> "" And Request("company") <> "") Then
		If (Request("reserve") = "no") Then
			Call MailSend(Request("company"))
		Else
			If (Request("reservation") <> "") Then
				Call MailSend(Request("company"))
			Else
				Response.write "<b>However, you did not enter all the required information.<br>Please click the link below, and try again.<br><br><a href=""[URL unfurl="true"]http://www.mycompany.com/opt/aim2005/emailform.htm"">http://www.mycompany.com/opt/aim2005/emailform.htm</a></b>"[/URL]
			End If
		End If
	Else
		Response.write "<b>However, you did not enter all the required information.<br>Please click the link below, and try again.<br><br><a href=""[URL unfurl="true"]http://www.mycompany.com/opt/aim2005/emailform.htm"">http://www.mycompany.com/opt/aim2005/emailform.htm</a></b>"[/URL]
	End If

Sub MailSend(company)
'	From
'	****
	mySmartMail.SenderName = Request("company")
	mySmartMail.SenderAddress = "ukaim@mycompany.com"

'	To
'	**
	mySmartMail.Recipients.Add "ukaim@mycompany.com", "Annual Investment Meeting 2005"

'	Message
'	*******
	mySmartMail.Subject = "AIM 2005 Response for company: " & Request("company")
	mySmartMail.Body = "This mail has been sent from: " & Request("name") & VbCrLf &_
		"Attending? " & VbTab & VbTab & VbTab & Request("attendaim") & VbCrLf &_
		"Informal Dinner? " & VbTab & VbTab & Request("dinnerinf") & VbCrLf &_
		"Main Dinner? " & VbTab & VbTab & Request("dinnermain") & VbCrLf &_
		"Reserve? " & VbTab & VbTab & VbTab & Request("reserve") & VbCrLf &_
		"Reservation Details: " & VbTab & Request("reservation") & VbCrLf
		
'	Send the message
'	****************
	mySmartMail.SendMail

	if Err.Number<>0 then

		Response.write "Error: " & Err.description

	else

		Response.write "An e-mail has just been sent to " & mySmartMail.Recipients.Item(1).Name & "."

	end if
End Sub

Essentially, the bit you'd want to change is:
mySmartMail.SenderName = strFrom
mySmartMail.SenderAddress = strEmailAddr

hth,

Will
[morning]
 
So, yours would be something like:

Code:
Set iMsg = CreateObject("aspSmartMail.SmartMail")
iMsg.Server = strIPAddress
iMsg.Recipients.Add "ToEmailSetHere@mycompany.com", "To Name Set Here"
iMsg.cc = strCC
iMsg.SenderAddress = strFromEmail
iMsg.SenderName = strFromName
iMsg.Subject = strSubject
iMsg.Body = strMessage
iMsg.SendMail

Will
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top