Hello all,
I have done some research, but I cannot find a solution to how to insert a clickable link to a file in the body of my CDO email through vba. My issue is that the file in each email differs. Also, due to clogging up employees inboxes, I cannot simply attach the file to the email. I appreciate any help you may offer! Here is the code I've been working with:
'enter path box to insert link to invoice
Private Sub Pathbox_Enter()
Dim Finfo As String
Dim FilterIndex As Integer
Dim Title As String
Dim FileName As Variant
Finfo = "All Files (*.*),*.*"
Title = "Select a file to import"
FileName = Application.GetOpenFilename(Finfo, FilterIndex, Title)
invoice_file_name = FileName
PathBox = "=HYPERLINK(""" & invoice_file_name & """, """ & InvoiceNumberBox.value & """)"
End Sub
Private Sub SaveButton_Click()
On Error Resume Next
Sheets("INVOICES").Activate
Dim rng As Range
Dim iMsg As Object
Dim iConf As Object
Dim Flds As Variant
Dim TextBody As String
Dim ApprovedTextBody As String
Dim Finfo As String
Dim FilterIndex As Integer
Dim FileName As Variant
Dim Title As String
Finfo = "All Files (*.*),*.*"
Title = "E-Mail Attachment: Select file to attach."
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
= mail_server
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With
TextBody = "Hello," & vbNewLine & vbNewLine & _
"Please review and approve the following invoice." & vbNewLine & vbNewLine & _
"The invoice can be found at: " & invoice_file_name & _
vbNewLine & vbNewLine & "Thank you," & vbNewLine & "cschoyer"
With iMsg
Set .Configuration = iConf
.To = "test@xyz.com"
.CC = ""
.BCC = ""
.From = """cschoyer"" <cschoyer@xyz.com>"
.Subject = "Approval Request "
.HTMLBody = TextBody
.Send
End With
Bookmarks