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

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,661 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,800 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sreeju Nair 12,186 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


0 additional answers

Sort by: Most helpful