mardi 27 janvier 2015

Excel/VBA send email with hyperlink and variable cell value

I have set up a standard module in workbook to send me an email. I am now stuck on two portions.



  1. I would like in the email to have the text "check list" by hyperlinked to http://"linktospreadsheet".html.

  2. The expiration date in the email text needs to be a variable value, dependent on a value within the linked spreadsheet.


Also, can someone provide a guide on how to execute this module when the items expiration date is actually approaching? Below is the code:



Option Explicit

Sub Mail_small_Text_Outlook()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String

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

strbody = "A plan is now # days from expiring" & vbNewLine & vbNewLine & _
"Please view the check list for details." & vbNewLine & vbNewLine & _
"http://ift.tt/1uZXWuN"
On Error Resume Next
With OutMail
.To = "name@email.com"
.CC = ""
.BCC = ""
.Subject = "Subject"
.Body = strbody
.Attachments.Add ("C:\test.txt")
.Send
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing
End Sub

Aucun commentaire:

Enregistrer un commentaire