Good Day Lads & Ladettes!
Tried to solve this in another thread but it wasn't going anywhere.
Below is my sub to send an automatic e-mail depending on the date in a Cell. Each row contains metadata about a file (a transmittal - PDF), and in column 'A' of that row it has a file number 'ENER-P12345-0413-001' which is also a hyperlink to the file in question. I'd like to use the hyperlink address stored in this cell to attach the file to them generated e-mail automatically. Does anyone know if this is possible? Or how to reference the hyperlink address stored within this cell?
Many thanks to anyone who can solve this one - I figure the data must be stored in the cell somewhere so it should be possible, but I'm no whiz kid like you macroids out there!
Sub SendEMail()
Dim Email As String, Subj As String
Dim Msg As String, URL As String
Dim DocT As String
Dim LastRow As Long, NextRow As Long, RowNo As Long
Dim wsEmail As Worksheet
Dim Attach As String
Set wsEmail = ThisWorkbook.Sheets("Transmittal Register")
With wsEmail
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For RowNo = 2 To LastRow
'Change "Date + 1" to suit your timescale
If .Cells(RowNo, "L") = "" And .Cells(RowNo, "I") <= Date + 1 Then
Email = .Cells(RowNo, "F")
DocT = .Cells(RowNo, "D")
Subj = "Automated E-mail - Document Due " & .Cells(RowNo, "I")
Attach = .Cells(RowNo, "A")
Msg = ""
Msg = "Good Day " & "," & vbCrLf & vbCrLf _
& "This is an automated e-mail to let you know that document" & vbCrLf _
& .Cells(RowNo, "C") & " - " & DocT & vbCrLf _
& "That was issued for " & .Cells(RowNo, "G") & " is due on " & .Cells(RowNo, "I") & "." & vbCrLf & vbCrLf _
& "Many Thanks, " & vbCrLf & vbCrLf & "AutoMech"
'Replace spaces with %20 (hex)
Subj = Replace(Subj, " ", "%20")
Msg = Replace(Msg, " ", "%20")
'Replace carriage returns with %0D%0A (hex)
Msg = Replace(Msg, vbCrLf, "%0D%0A")
'Create the URL
URL = "mailto:" & Email & "?subject=" & Subj & "&Attachments=" & Attach & "&body=" & Msg
'Execute the URL (start the email client)
ShellExecute 0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus
'Return Flag
.Cells(RowNo, "L") = "X"
End If
Next
End With
End Sub
Bookmarks