Forum Moderators: open

Message Too Old, No Replies

Replacing a character in an email address

         

grayhammy

10:35 pm on Nov 19, 2005 (gmt 0)

10+ Year Member



Hi,

I am trying to automate the process of taking an email address from a contact form and sending it to the unique email address that will add the person to my mailing list.

This unique address is formed from the users own email address. So for john@hotmail.com, the subscribe address would be:

mailinglist-subscribe-john=hotmail.com@mywebsite.com

What I am trying to do is take the @ sign in John's email, replace it with a =, and then send the email. My code is as follows:

<%
Dim objMail

'Create the mail object
Set objMail = Server.CreateObject("CDO.Message")

'Replace the @ sign with an =
newEmail = Replace Request(Email,'@','=')

'Set key properties
objMail.From = Request("Email")
objMail.To = "mailinglist-subscribe-" & 'newEmail' & "@mywebsite.com"
objMail.Subject= "Mailing List addition"
objMail.TextBody = "Email" & ": " & Request("Email")

'Send the email
objMail.Send

'Clean-up mail object
Set objMail = Nothing
response.redirect "redirect.html"
%>

I can't work out how to write the changed email address in the string... I am sure it is really simple but I am not an ASP programmer, so I don't know the syntax of the language well enough to know how to write this in.

Any help would be much appreciated...

G

grayhammy

10:58 am on Nov 20, 2005 (gmt 0)

10+ Year Member



I have worked it out thanks. Realised you don't have to put newEmail in any quotations at all for it to work. New (working) code for anyone who wants to see:

<%
Dim objMail

'Create the mail object
Set objMail = Server.CreateObject("CDO.Message")

'Replace the @ sign with an =
newEmail = Replace (Request("Email"),"@","=")

'Set key properties
objMail.From = Request("Email")
objMail.To = "mailinglist-subscribe-" & newEmail & "@mywebsite.com"
objMail.Subject= "Mailing List addition"
objMail.TextBody = "Email" & ": " & Request("Email")

'Send the email
objMail.Send

'Clean-up mail object
Set objMail = Nothing
response.redirect "redirect.html"
%>