Putting an active link in HTMLBody in CDO

corquando

Board Regular
Joined
Jan 8, 2009
Messages
82
Greetings, all.

I have tried without success to put an active link to a URL in the body of an email.

I'm simply going through a database of email addresses and sending each one an email asking to click on a link to go someplace really cool and awesome.

Instead of descriptions, here's the code:

Rich (BB code):
        For i = 2 To x
            If Range("A" + CStr(i)) = "" Then GoTo 27
            Set iMsg = CreateObject("CDO.Message")
            Set iConf = CreateObject("CDO.Configuration")
 
            iConf.Load -1     'CDO Source Defaults
 
            On Error GoTo 27  'Bad address bailout
 
            Set Flds = iConf.fields
            With Flds
                .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
                .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
                = "MY-EXCHMAIL.massive"
                .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
                .Update
            End With
 
                StrBod = "< HTML >"
                StrBod = StrBod & "< HEAD >< /HEAD >"
                StrBod = StrBod & "< BODY >"
                StrBod = StrBod & "Dear Valued People(s),< p >< p >"
                StrBod = StrBod & "Blahblahblah.< p >< p >"
                StrBod = StrBod & "Blahblahblah..< p >< p >"
                StrBod = StrBod & "Please click on the link below for more information.< p >< p >"
                StrBod = StrBod & "Sincerely,< p >< p >"
                StrBod = StrBod & "Your Marvelous Friends< p >< p >"
                StrBod = StrBod & "< a href = http://www.wxyz.com/and/so_on/and/so_forth.html >< /a >"  
                StrBod = StrBod & "< /BODY >"
                StrBod = "< /HTML >"
          End If
 
            Subj = "Howdy, folks"
            EML = Range("B" + CStr(i)) 'Email address record
 
            With iMsg
                Set .Configuration = iConf
                .To = EML
                .CC = ""
                .BCC = ""
                .From = "Us@OurOutbox"
                .Subject = Subj
                .HTMLBody = StrBod
 
 
            Set iMsg = Nothing
            Set iConf = Nothing
            Set Flds = Nothing
27      Next

(The spaces between the "<" & ">" are on purpose so the code doesn't try to execute.)

When I do this, I get the body of the email exactly as I want it, but the link refuses to show up.

I'm sure it's something vibrantly stupid or else I wouldn't be missing it.

Thanks to all who try, success or not.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
have you tried just using the A tag alone, without the hyperlink ref accompanying? if I remember correctly, outlook doesn't recognize the href
 
Upvote 0
Dang. Just tried it and no soap. The email comes through w/ no link, just as before.

But thanks bzillions anyway. I'll try anything once.
 
Upvote 0
Perhaps attempt to record a macro in Outlook doing what you want it to do and then peeking at the code to see how it handles?

Heck, I honestly don't even know if you can record a macro in Outlook, so I might just be blowing smoke...:eek:
 
Upvote 0
The anchor tag looks wrong to me. shouldn't the href be in quotes, and some text provided?

<a href="xxx">anchor text</a>
 
Upvote 0
The anchor tag looks wrong to me. shouldn't the href be in quotes, and some text provided?

<a href="xxx">anchor text</a>

nice catch! and I still don't think href works in outlook. :p would love to be proven wrong though!
 
Upvote 0
On some other sites I've found, the authors mentioned that the quotes are optional, and only used for "appraising," whatever that is. In any event, I've tried single quotes, double quotes and, as seen in my example, no quotes at all. The results are always the same.

So again, thanks for the input - nothing is ever wasted on these forums as somebody may find use out of all of it, but so far no go.

I'll do some digging regarding href and Outlook - I can't imagine why that would be the case, but MS has always defied logic . . . perhaps there's another code for encapsulating or some such.

Thanks again!
 
Upvote 0
I think you need to enclose the URL in double quotes (two sets) as in:

http://www.bigresource.com/Tracker/Track-asp-rAgbjQJL/

It's 2 because the entire string is already in double quotes. Only 1 will be used.

Just tried that, and it turned out the same. I'm beginning to believe it's either an Outlook quirk (as previously hinted at) or perhpas there are filters, firewalls and moats on my company's system that prevent this kind of link from being sent. It may be that such constructs too closely resemble nasty, virus-laden emails or the like.

Nonetheless I willc ontinue, as the suggestions keep flooding in.

Again, thanks to everybody. Even without success (so far) this is a great experience!
 
Upvote 0

Forum statistics

Threads
1,213,560
Messages
6,114,304
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top