VBA Code to insert hyperlink into an email

L_Corc

New Member
Joined
Nov 8, 2016
Messages
1
Hello,
I have the following VBA code written for a macro executed when a button is pushed. It works fine (the goal is that it sends an email via Lotus Notes to a specified mailbox when the button is pushed.) However, I would like to have the email message include a hyperlink, and I cannot figure out how to do that. The part I want hyperlinked is where it says "Checklist Location:"

Thank you in advance for your help.
Laura

Code:
Sub InitiateChecklist()
Dim noSession As Object, noDatabase As Object, noDocument As Object
    Dim obAttachment As Object, EmbedObject As Object
    Dim stSubject As Variant, stAttachment As String
    Dim vaRecipient As Variant
    Dim vaMsg As Variant
    Dim valink As Variant
 
    Const EMBED_ATTACHMENT As Long = 1454
    Const stTitle As String = "Status Active workbook"
    Const stMsg As String = "The active workbook must first be saved " & vbCrLf _
     & "before it can be sent as an attachment."
 
   'If the active workbook has not been saved at all.
    If Len(ActiveWorkbook.Path) = 0 Then
        MsgBox stMsg, vbInformation, stTitle
        Exit Sub
    End If
 
    Dim X As Integer
    For X = 1 To 1
        'Get the name of the recipient from the user.
        vaRecipient = "[EMAIL="PMCMQualityAssurance@usbank.com"]PMCMQualityAssurance@usbank.com[/EMAIL]"
 
    Do 'Get the message from the user.
           vaMsg = "Hello," & vbNewLine & vbNewLine & _
            "Please refer to the link below for the following campaign checklist, which is now initated and stored in the repository location below:" & vbNewLine & vbNewLine & _
            "Campaign:" & " " & Worksheets("PMCM Checklist").Range("C2") & vbNewLine & vbNewLine & _
            "Program/Offer:" & " " & Worksheets("PMCM Checklist").Range("C3") & vbNewLine & vbNewLine & _
            "Checklist Location:" & " " & ActiveWorkbook.FullName & vbNewLine & vbNewLine & _
            "I have sent the checklist location to the appropriate contacts in Marketing Fulfillment, RIO, and PCM as applicable." & vbNewLine & vbNewLine & _
           "Thank you!"
 
           
    Loop While vaMsg = ""
    If vaMsg = False Then Exit Sub   'If the user has canceled the operation.
 
    'Add the subject to the outgoing e-mail which also can be retrieved from the users
    'in a similar way as above.
     stSubject = Worksheets("PMCM Checklist").Range("C2").Value & "-Initiated Checklist"
 
 
    'Retrieve the path and filename of the active workbook.
     stAttachment = ActiveWorkbook.FullName
 
    'Instantiate the Lotus Notes COM's Objects.
     Set noSession = CreateObject("Notes.NotesSession")
     Set noDatabase = noSession.GETDATABASE("", "")
 
     'If Lotus Notes is not open then open the mail-part of it.
      On Error Resume Next
      If noDatabase.IsOpen = False Then noDatabase.OPENMAIL
 
    'Create the e-mail
     Set noDocument = noDatabase.CreateDocument
 
    'Add values to the created e-mail main properties.
     With noDocument
        .Form = "Memo"
        .sendto = vaRecipient
        .Subject = stSubject
        .Body = vaMsg
        .SaveMessageOnSend = True
     End With
 
    'Send the e-mail.
     Dim myMessage As String
     myMessage = MsgBox("Are you sure you want to send your initiated Checklist location?", vbYesNo, "Are you sure?")
 
     If myMessage = vbYes Then
         With noDocument
             .PostedDate = Now()
             .SEND 0, vaRecipient
         End With
    'Release objects from the memory.
    Set EmbedObject = Nothing
    Set obAttachment = Nothing
    Set noDocument = Nothing
    Set noDatabase = Nothing
    Set noSession = Nothing
 
       'Activate Excel for the user.
       AppActivate "Microsoft Excel"
 
          MsgBox "The e-mail has successfully been created and distributed. Please send Checklist location to your supporting team members via email now.", vbInformation, "Done!"
      Else
       MsgBox "Unsent email!", vbInformation, "Unsent email"
      End If
     Next X
  End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,216,037
Messages
6,128,440
Members
449,453
Latest member
jayeshw

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