6

When you attach a document to an outlook email, a copy of the document is created and stored somewhere. You can obviously link to any location in the body of outlook. A hyperlink to a local document will not be useful to a recipient on another machine (without access to the local drive).

But, is there a way to hyperlink to an attached file? I don't think that there is any native way to do this, but is there any possible solution?

If it matters, the email will only be read by outlook. (i.e. intra office).

TiredofGoogling
  • 197
  • 1
  • 2
  • 9

2 Answers2

4

Sure, you can refer to an attachment by its content-id. Look at the code below setting the <a> tag in the HTML body and the PR_ATTACH_CONTENT_ID property on the attachment:

set msg = Application.CreateItem(0)
msg.To = "user@domain.demo"
msg.Subject = "test link"
msg.HTMLBody = "<html><body>click <a href=""cid:attachCid"">here</a> to open attachment</body></html>"
set attach = msg.Attachments.Add("c:\temp\test.txt")
attach.PropertyAccessor.SetProperty "http://schemas.microsoft.com/mapi/proptag/0x3712001F", "attachCid"
msg.Send
Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
0

Using this code

Set msg = Application.CreateItem(0)
msg.Display
msg.To = "user@domain.demo"
msg.Subject = "test link"
msg.HTMLBody = "<html><body>click <a href=""cid:attachCid"">here</a> to open attachment</body></html>"
Set attach = msg.Attachments.Add("c:\temp\test.txt")
attach.PropertyAccessor.SetProperty "http://schemas.microsoft.com/mapi/proptag/0x3712001F", "attachCid"

As BrainSlugs83 wrote, when I run it and click on the link "here" in the mail body, I get a security notice and then I cannot continue as no fitting app is found to open the cid: link.

RalphJ
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 18 '22 at 23:16