question

poojaghatge-1170 avatar image
0 Votes"
poojaghatge-1170 asked WendyLi-MSFT edited

add button to HTML body

Can I add a button inside the HTMLBody which would in turn open a sharepoint document in this code :

Sub send_email()
Dim OutApp As Object
Dim OutMail As Object

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = "XYZ"
.CC = "XYZ"
.Subject = " Hello, good morning"
.Send

End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing

End Sub

dotnet-visual-basicsharepoint-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

sreejukg avatar image
0 Votes"
sreejukg answered poojaghatge-1170 commented

What I understand is that you need to add a hyperlink to the email body, where the hyperlink points to the SharePoint document. So basically you need to send some body to the email with HTML contents enabled. try the following.

 On Error Resume Next
 With OutMail
   .To = "XYZ"
   .CC = "XYZ"
   .Subject = " Hello, good morning"
 .BodyFormat = olFormatHTML
 .HTMLBody =  "<HTML><BODY><a href='link to the document here'>Click here to open the document</a> </BODY></HTML>" 
   .Send

Hope this helps

Refer: https://docs.microsoft.com/en-us/office/vba/api/outlook.mailitem.htmlbody

End With

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks so much, that worked.

0 Votes 0 ·