Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hyperlink to Outlook Attachment

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).

like image 421
TiredofGoogling Avatar asked Apr 25 '16 23:04

TiredofGoogling


1 Answers

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 = "[email protected]"
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
like image 139
Dmitry Streblechenko Avatar answered Oct 17 '22 04:10

Dmitry Streblechenko