Hi Guys

I am trying to send a link in an email to my users - I am using CDO. I am having trouble contructing the link. Currently I am receiving the message "syntax error".

strBody = strBody & <a name= & "anchor" & id= & (rsEmailAlert.Fields.Item("S_Id").value) &  href= & " http://www.hair-salons.com/Hair-Salon-Search.asp" & > & "CLICK HERE" & </a> & vbCrLf

Any help would be great:)

Hi Guys

strBody = strBody & <a name= & "anchor" & id= & (rsEmailAlert.Fields.Item("S_Id").value) &  href= & " http://www.hair-salons.com/Hair-Salon-Search.asp" & > & "CLICK HERE" & </a> & vbCrLf

Any help would be great:)

Your Code should look like this:

strBody = strBody & "<a name=" & anchor & " id=" & (rsEmailAlert.Fields.Item("S_Id").value) & " href='http://www.hair-salons.com/Hair-Salon-Search.asp'>Click Here</a>" & vbCrLf

This should work. Let me know if it doesn't.

Hi

Thanks for your reply.

The email is sent ok but the link appears like this:

<a name= id=1 href='http://www.hair-salons.com/Hair-Salon-Search.asp'>Click Here</a>

At the moment the <a name> is empty and I was hoping the link might appear in the email like this:

Click Here

..

It sounds like you are sending mail using text format. Make sure that you include this in your script:

myMail.BodyFormat = 0 
myMail.MailFormat = 0

Also, is the name supposed to equal "anchor" or is "anchor" a variable that should = something else?

If name=anchor then use this code:

strBody = strBody & "<a name='anchor'  id='" & (rsEmailAlert.Fields.Item("S_Id").value) & "' href='http://www.hair-salons.com/Hair-Salon-Search.asp'>Click Here</a>" & vbCrLf

Hope this helps.

Works well - Thanks for all your help.

commented: great question. +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.