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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding an email domain to name

Status
Not open for further replies.

rjblanch

Programmer
Jan 16, 2003
257
AU
Hi all,

I currently have an form that has an input of an email address to send to. What I wish to try and do is change the "To" field so that it only requires a name to be put in with the email domain automatically inserted. So basically, I wish someone to put in JSMITH and then the To email address would work out to be JSMITH@domain.com

This is the code that i have used -

If (cStr(Request("Submit")) <> "") Then
Dim objCDO
Set objCDO = Server.CreateObject("cdonts.NewMail")
objCDO.From = cStr(Request("varFrom")) 'Senders Email Address
objCDO.To = cStr(Request("varTo")) 'Recipient Email Address
objCDO.CC = cStr(Request("varCC")) 'Carbon Copy Address
objCDO.Subject = cStr(Request("varSubject")) 'Email Subject
objCDO.Body = cStr(Request("varMessage")) 'Email Message
objCDO.Send() 'Send email
Set objCDO = Nothing 'Clean up your objects!!!
'Response.Redirect("thanks.asp") 'use this to redirect page after delivery
Response.Write("Message Delivered") 'default response
End If
%>

Thank you for any assistance...

 
At its absolute simplest;

If (cStr(Request("Submit")) <> "") Then
Dim objCDO
Set objCDO = Server.CreateObject("cdonts.NewMail")
Dim sDomainName
sDomainName = "@Domain.com"

objCDO.From = cStr(Request("varFrom") 'Senders Email Address
objCDO.To = cStr(Request("varTo") & sDomainName) 'Recipient Email Address
objCDO.CC = cStr(Request("varCC") & sDomainName) 'Carbon Copy Address
objCDO.Subject = cStr(Request("varSubject")) 'Email Subject
objCDO.Body = cStr(Request("varMessage")) 'Email Message
objCDO.Send() 'Send email
Set objCDO = Nothing 'Clean up your objects!!!
'Response.Redirect("thanks.asp") 'use this to redirect page after delivery
Response.Write("Message Delivered") 'default response
End If



However, there's no data validation going on... if a user types the domain name, this code will send to "JSMITH@domain.com@domain.com". Also, can users enter more than one address in a field? If so you will need to handle this differently.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top