HELP: email file path as a hyperlink in outlook body

S

sam

Hi All,

I am trying to send a file path as a hyperlink in outlook once user clicks
"Submit" on an excel userform.

I am able to send the path, but the hyperlinking doesnt work on all of the
path, maybe because of a space in the file name?

Here is what I have so far..

With OutMail
.to = "(e-mail address removed)"
.CC = ""
.BCC = ""
.Subject = "Hyperlink test "
.Body = "Hyperlink: " & "C:\Documents" & Me.FileName.Value

..Send

Here Me.FileName.value is the actual file name that it will be saved with.
The file name has a space somethign like "abc 123"

Hope I made it clear.

Thanks in advance
 
B

Barb Reinhardt

Have you tried this

..Body = "Hyperlink: " & "C:\Documents" & _
Replace(Me.FileName.Value ," ","%20")
 
S

sam

Thanks for the help Barb, I cannot replace the space with anything else, The
file is saved with a space in between, "123 455" and I have to get it to work
as a link with the space in the file name,
actually the whole path with the file name as a hyperlink.
 
D

Dave Peterson

I'm not sure what me.filename.value (textbox on a userform???) is, but maybe...

(This is untested...)

dim myFileName as string
myfilename = replace(me.filename.value, " ", "%20")

....
'don't forget the trailing backslash for the path.
..body = "hyperlink: c:\documents\" & myfilename

=========

I would have thought that:
..body = "hyperlink: file:\\\\c:\documents\" & myfilename

Would work better...(But it's still untested)
 
D

Dave Peterson

The %20 is hex for the space character.

It's a way to include the space character into the link without confusion.
 
S

sam

Thanks for helping dave,

When i use: Replace(Me.filename.value, " ", "%20") I see "%20" between the
space.
like this:

123%20abc (123 abc: being the original file name)

And yes, Me.filename.value is a textfield in the userform, And I am saving
the file with that field name as the file name
 
S

sam

Thanks for helping ron,

I have spaced in between so i am not able to show the entire thing as a link,

the path is somewhat like:

C:\My Documents\

there is a space between "My" and "documents"

File name is:

Me.filename.value

There is a space between in file name as well, eg, "123 abc"
 
D

Dave Peterson

That's the purpose of the doing the replace. Instead of two separate strings,
you have a long string.

Did the hyperlink work when you used this?

If no, did you include the "File:////" stuff?
 
J

JP

Email format? Is it RTF, HTML, or plain text?

Instead of the Body Property, how about the HTMLBody Property?

..HTMLBody = "<p><a href=" & Chr(34) & "C:\My Documents\" &
Me.FileName.Value & Chr(34) & ">My File</a></p>"

--JP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top