Share via

add button to HTML body

pooja ghatge 81 Reputation points
2022-04-24T00:22:09.037+00:00

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

Microsoft 365 and Office | SharePoint | Development
Developer technologies | VB
0 comments No comments

Answer accepted by question author

Sreeju Nair 12,761 Reputation points
2022-04-24T04:57:00.727+00:00

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://learn.microsoft.com/en-us/office/vba/api/outlook.mailitem.htmlbody

End With

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.