Link sent via outlook does not open

Monikbor

New Member
Joined
Nov 2, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello,

I really need your help here... I have been looking for the answer for too long now, without success.

I have a user form where the user "uploads" a document. Then, the path to the document is recorded onto the spreadsheet (and it works properly).
Now, I am trying to send the link to that document via outlook.
However, I keep on receiving an error message:

<Error>
<Code>AccountRequiresHttps</Code>
<Message>The account being accessed does not support http. RequestId:xxxxx Time:2021-11-02T18:49:05.4834541Z</Message>
<AccountName>parentdomain</AccountName>
</Error>

When I hover over the link in the mail, I see the address to the file is not complete, it gets cut half way through.
Additionally, I see the path begins with http, but that is not what I mean. The link I want to send leads to a file in the shared drive.


Here is my code:

Dim sh As Worksheet
Dim Currentrow As Long
Dim hyp As Object
Dim lien As String
Dim email As Outlook.Application
Dim NewEmail As Outlook.MailItem

Set email = New Outlook.Application
Set NewMail = email.CreateItem(olMailItem)
Set sh = ThisWorkbook.Sheets("2021-CSM")

Currentrow = ActiveCell.Row

With sh

Set hyp = sh.Cells(Currentrow, 54)
Dim sName As String
sName = CreateObject("scripting.filesystemobject").getbasename(UserForm2.LabelDocPath.Caption)
hyp.Parent.Hyperlinks.Add Anchor:=hyp, Address:=UserForm2.LabelDocPath.Caption, TextToDisplay:=sName

lien = hyp.Hyperlinks.Item(1).Address

End With

NewMail.SentOnBehalfOfName = "usermane@dominion.ca"
NewMail.To = "username@dominion.ca"
' NewMail.CC = "username@dominion.ca"
NewMail.Subject = "RGA " & sh.Cells(Currentrow, 5) & " a été reçu - " & sh.Cells(Currentrow, 27)

NewMail.HTMLBody = "Bonjour," & "<BR><BR>" & _
"On vient de recevoir le RGA # " & sh.Cells(Currentrow, 5) & _
"<BR>" & _
"Voici le lien vers les documents de reception:" & "<a href=" & lien & ">Click here</a>" & _
"<BR><BR>" & _
"Merci,"

NewMail.Send

Thanks in advance for your help,
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Hi & welcome to MrExcel.

In the code line below there's an essential part missing.
VBA Code:
"Voici le lien vers les documents de reception:" & "<a href=" & lien & ">Click here</a>" & _

Replacing it with this line might resolve your issue:
VBA Code:
"Voici le lien vers les documents de reception: <a href=""file:///" & lien & """>Click here</a>" & _
 
Upvote 0
Solution

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top