It just occurred to me that I may have just put it into my sub wrong, so here's how I've input it
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
Dim OutApp As Object
Dim OutMail As Object
Dim bng As Range
Dim FPath As String
Dim Ease As String
Dim FName As String
Dim a() 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
On Error Resume Next
Set OutApp = GetObject("Outlook.Application")
On Error GoTo 0
If OutApp Is Nothing Then Set OutApp = CreateObject("Outlook.Application")
Do: Loop Until Not OutApp Is Nothing
Set OutMail = OutApp.CreateItem(0)
Set bng = wsEmail.Cells(RowNo, "A")
FPath = Application.ActiveWorkbook.Path
FName = bng.Hyperlinks(1).Address
Ease = FPath & "\" & FName
a = Split(wsEmail.Cells(RowNo, "F"), ";")
For x = LBound(a) To UBound(a)
email = email & Sheets("contacts").Range("c" & Application.WorksheetFunction.Match(a(x), Sheets("Contacts").Range("K:K"), -1)) & "; "
Next x
email = Left(email, Len(email) - 1)
MsgBox email
With OutMail
DocT = wsEmail.Cells(RowNo, "D")
SubJ = "Automated E-mail - Document Due " & wsEmail.Cells(RowNo, "I")
Msg = ""
Msg = "Good Day" & "," & vbCrLf & vbCrLf _
& "This is an automated e-mail to let you know that document" & vbCrLf _
& wsEmail.Cells(RowNo, "C") & " - " & DocT & vbCrLf _
& "That was issued for " & wsEmail.Cells(RowNo, "G") & " is due on " & wsEmail.Cells(RowNo, "I") & "." & vbCrLf & vbCrLf _
& "Many Thanks, " & vbCrLf & vbCrLf & "AutoMech"
.To = email
.CC = ""
.SentOnBehalfOfName = "PPU Document Control"
.Subject = SubJ
.ReadReceiptRequested = False
.Body = Msg
.Attachments.Add (Ease)
.Display
End With
Set OutApp = Nothing
Set OutMail = Nothing
Set bng = Nothing
.Cells(RowNo, "Q") = Date
End If
If .Cells(RowNo, "L") = "RS" And .Cells(RowNo, "Q") <= Date - 3 And .Cells(RowNo, "Q") <> "" Then
.Cells(RowNo, "Q") = Date
On Error Resume Next
Set OutApp = GetObject("Outlook.Application")
On Error GoTo 0
If OutApp Is Nothing Then Set OutApp = CreateObject("Outlook.Application")
Do: Loop Until Not OutApp Is Nothing
Set OutMail = OutApp.CreateItem(0)
Set bng = wsEmail.Cells(RowNo, "A")
FPath = Application.ActiveWorkbook.Path
FName = bng.Hyperlinks(1).Address
Ease = FPath & "\" & FName
With OutMail
email = wsEmail.Cells(RowNo, "F")
DocT = wsEmail.Cells(RowNo, "D")
SubJ = "Automated E-mail - Document Due " & wsEmail.Cells(RowNo, "I")
Msg = ""
Msg = "Good Day" & "," & vbCrLf & vbCrLf _
& "This is an automated e-mail to let you know that document" & vbCrLf _
& wsEmail.Cells(RowNo, "C") & " - " & DocT & vbCrLf _
& "That was issued for " & wsEmail.Cells(RowNo, "G") & " is due on " & wsEmail.Cells(RowNo, "I") & "." & vbCrLf & vbCrLf _
& "Many Thanks, " & vbCrLf & vbCrLf & "AutoMech"
.To = email
.CC = ""
.SentOnBehalfOfName = "PPU Document Control"
.Subject = SubJ
.ReadReceiptRequested = False
.Body = Msg
.Attachments.Add (Ease)
.Display
End With
Set OutApp = Nothing
Set OutMail = Nothing
Set bng = Nothing
.Cells(RowNo, "L") = "RS"
End If
Next
End With
End Sub
Bookmarks