0

I can't find the solution for my problem. So, in my send-mailmessage html body is field that should be redirected to file which is included as attachment in message. How can I create hyperlink to that file in mail, when client opens it?

I don't know if you get my idea. In other words, in message I have attached file, and then there is field which should be a hyperlink to attached file. When client receives message he/she should press the link and then attached file opens.

I searched almost everything in everwhere but can't find a appropriate solution how to solve this.

Kiquenet
  • 14,494
  • 35
  • 148
  • 243
safazaurs
  • 1
  • 2

2 Answers2

0

This isn't really a PowerShell question, since this issue has nothing to do with the functionality of the Send-MailMessage cmdlet.

In any case, the reason you can't find a solution anywhere is that what you're trying to do is impossible. There is no way that a hyperlink in an e-mail message can point to a file attached to that message. Different mail clients on different operating systems store attachments in different locations. Even if you want to assume that all your recipients are running Outlook on Windows, there are different versions of both. Even if you know for a fact that all recipients are running a specific version of Outlook on a specific version of Windows, you're still out of luck. Outlook stores attachments in a subfolder in the Temporary Internet Files in the user's profile that has a randomly generated name. There's no way to inject code into a hyperlink in an email message, so without knowing the exact local file location, you can't link to it.

I suppose if you're really determined you could have the hyperlink point to a web page that runs some complex javascript code that tries to figure out where the attachment is stored, but that's a major undertaking, and would break if the recipient's default browser has javascript disabled.

Which begs the question, why exactly are you trying to do this? So that recipients can click once instead of having to double-click to open the attachment?

Adi Inbar
  • 12,097
  • 13
  • 56
  • 69
0

I have found that you can make a hyperlink point to a file share that you know the recipients have access to.

To do so:

  • Simply make each hyperlink point to the specific file and there you have it.
  • They have to have permissions to access that file share, or there is a much better way now that I haven't thought of.

Oh well, this works for me, for now.

AP.
  • 8,082
  • 2
  • 24
  • 33
Nobi
  • 1