PDA

View Full Version : [SOLVED] HTML href cutting off URL at first space



MINCUS1308
05-29-2018, 06:39 AM
I have a sub that sends an email (with an attachment and a link to the file)
It worked just fine up until last week. (2+ years - without modifying the file)


'EMAIL BODY
Dim MailTxt As String
MailTxt = "<p>Attached is a copy of the updated Report.</p>" & _
"<a href=" & ActiveWorkbook.FullName & ">Report</a>"

Immediately after assigning MailTxt the link is correct.
The Email is sent but when I click the link in the email - Outlook says it cant open the link.
The msgbox displays the link up until the first space.

Example:
Desired Link: L:\Segment\Region\Company\Department\Daily Reports\My First Report.xlsm
Link after assignment to MailTxt in VB: L:\Segment\Region\Company\Department\Daily Reports\My First Report.xlsm

Link sent in email: L:\Segment\Region\Company\Department\Daily

In testing - I removed the space from 'Daily Reports' an then sent the email and got the following link:
L:\Segment\Region\Company\Department\DailyReports\My


I'm not sure what changed, but does anyone have a solution / alternate method of sending he link?

MINCUS1308
05-29-2018, 07:02 AM
I was able to resolve the problem by replacing the spaces in the UNC with "%20"

'EMAIL BODY
Dim MailTxt As String
MailTxt = "<p>Attached is a copy of the updated Report.</p>" & _
"<a href=" & Replace(CStr(ActiveWorkbook.FullName), " ", "%20") & "> Report</a>"

I still don't understand why this stopped working after 2 years?