E-mail hyperlinks not working from a table ... (1 Viewer)

Local time
Today, 07:37
Joined
Feb 28, 2023
Messages
628
This will be hard to explain, but it used to work and now it does not - both in Office 2016 and Office M365.

I am generating E-mails from my Database. The E-mail body is in an external table .(so that I can change the text of the link addresses without releasing an updated database).

Inside the database, this works:
Code:
Sub Test()
strbody = "<p style='font-family:calibri (Body);font-size:15'>Files are available in the <a href=""\\Network Path with spaces"">Network Path</a> folder.</p>"
Call SendEmail
End Sub
If I copy the StrBody line into my table, this USED to work:
Code:
SubTest
strbody = Nz(ELookup("[EM_Body]", "[tblEmail]", "[Group] = 'Group A'"), "")
Call SendEmail
End Sub

Recently, this stopped working. The E-mail is generated and it LOOKS like it contains hyperlinks, but the link addresses are empty and nothing happens when you click on them.

However, elsewhere in the database, I have a table with nothing but directory paths in the fields and this works:
Code:
Sub Test()
strbody = "<p style='font-family:calibri (Body);font-size:15'>Files are in the <a href=" & Replace(Nz(ELookup("[NetworkPath]", "[tblNetworkPaths]", "[NetworkName] = 'Path3'"), ""), Space$(1), "%20") & """>Network Path</a> folder.</p>"
Call SendEmail
End Sub

It is not the issue with "%20" in place of " " because I don't have that in the internal database and I added it to the table and it still didn't work.

Unless I'm missing something obvious (which is likely), I see two options:
  • I can hard-code the e-mail body in the database and it will work as desired, but I'll have to put out a database revision if I ever need to update it.
  • I can PROBABLY add the links to the network paths table, and save them as variables and change my EM_BODY field text to call out the links, but I'm not sure why this is required (especially since it USED to work without it).
 

plog

Banishment Pending
Local time
Today, 06:37
Joined
May 11, 2011
Messages
11,646
The E-mail is generated and it LOOKS like it contains hyperlinks,

You're looking everywhere but where you need to. The code that is producing the HTML is helpful, the email client that interprets the HTML is also helpful. But you need to see the actual HTML that is being produced.

You can do this by spitting out the HTML being produced by using Debug.Print in VBA, spitting the HTML to a blank file or viewing the source on the email client you are using. When you do that you will know exactly what is being produced by your script instead of guessing from one step before or one step after.

Most likely it is has something with quotes and/or slashes being retrieved from your database that will require you to escape/unescape them.
 
Local time
Today, 07:37
Joined
Feb 28, 2023
Messages
628
Okay, there's an error, but I still don't see what it is or what causes it.

If I Debug.Print the .HTMLBody I see this (Obfuscated):
... Files are available in the <span style='mso-field-code:" HYPERLINK \0022\0022 "'><span >Network_Path</span></span> folder. ...

Which to me looks like a link with no target, but WHY?
 

plog

Banishment Pending
Local time
Today, 06:37
Joined
May 11, 2011
Messages
11,646
I see no link html (<a>), I see 2 nested spans.

I'm kind of confused what code you are working with, but if you are retreiving something from the database via DLookup, I would investigate exactly what is being returned.

Divide and conquer or keep dividing until you can conquer.
 

plog

Banishment Pending
Local time
Today, 06:37
Joined
May 11, 2011
Messages
11,646
So find out what exactly is being pulled from the database. Then find out what the entire string looks like after you put them together.
 
Local time
Today, 07:37
Joined
Feb 28, 2023
Messages
628
I'm not going to post the network names for obvious reasons, but everything looks okay to me.

I.e. in the first post I have:
Files are available in the <a href=""\\Network Path with spaces"">Network Path</a> folder.
Which works.
In the second instance, if I do a debug.print of StrBody after the ELookup line, the link looks the same.

But in the second instance, the target of the E-mail link is empty.
 

Users who are viewing this thread

Top Bottom