Cookey5599
New Member
- Joined
- Mar 22, 2022
- Messages
- 17
- Office Version
- 365
- Platform
- Windows
Good afternoon and apologies of this has already been asked but I cant find a thread that details this particular issue.
We have a supplier approval log that shows when a particular certificate expires, as you can see form the attachment it is possible that one supplier could hold multiple certs with multiple expiry dates.
I have amended the following code so that it checks column V and sends an email accordingly, what I cant seem to do is get it to check the other cells (n,r,aa & af)
Private Sub Workbook_Open()
Dim OutApp As Object
Dim OutMail As Object
Dim lLastRow As Long
Dim lRow As Long
Dim sSendTo As String
Dim sSendCC As String
Dim sSendBCC As String
Dim sSubject As String
Dim sTemp As String
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
' Change the following as needed
sSendTo = "test@company.com"
sSendCC = ""
sSendBCC = ""
sSubject = "Due date reached"
lLastRow = Cells(Rows.Count, 3).End(xlUp).Row
For lRow = 2 To lLastRow
If Cells(lRow, 23) <> "S" Then
If Cells(lRow, 22) <= Date Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = sSendTo
If sSendCC > "" Then .CC = sSendCC
If sSendBCC > "" Then .BCC = sSendBCC
.Subject = sSubject
sTemp = "Hi Luke" & vbCrLf & vbCrLf
sTemp = sTemp & "The Quality ceritifcate has expired "
sTemp = sTemp & "for this supplier:" & vbCrLf & vbCrLf
' supplier name is in column F
sTemp = sTemp & " " & Cells(lRow, 6) & vbCrLf & vbCrLf
sTemp = sTemp & "Please take the appropriate "
sTemp = sTemp & "action." & vbCrLf & vbCrLf
sTemp = sTemp & "BR" & vbCrLf
.Body = sTemp
' Change the following to .Send if you want to
' send the message without reviewing first
.Display
End With
Set OutMail = Nothing
Cells(lRow, 23) = "S"
Cells(lRow, 24) = "E-mail sent on: " & Now()
End If
End If
Next lRow
Set OutApp = Nothing
End Sub
If anyone has any suggestions then I would be eternally grateful.
Thanks
We have a supplier approval log that shows when a particular certificate expires, as you can see form the attachment it is possible that one supplier could hold multiple certs with multiple expiry dates.
I have amended the following code so that it checks column V and sends an email accordingly, what I cant seem to do is get it to check the other cells (n,r,aa & af)
Private Sub Workbook_Open()
Dim OutApp As Object
Dim OutMail As Object
Dim lLastRow As Long
Dim lRow As Long
Dim sSendTo As String
Dim sSendCC As String
Dim sSendBCC As String
Dim sSubject As String
Dim sTemp As String
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
' Change the following as needed
sSendTo = "test@company.com"
sSendCC = ""
sSendBCC = ""
sSubject = "Due date reached"
lLastRow = Cells(Rows.Count, 3).End(xlUp).Row
For lRow = 2 To lLastRow
If Cells(lRow, 23) <> "S" Then
If Cells(lRow, 22) <= Date Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = sSendTo
If sSendCC > "" Then .CC = sSendCC
If sSendBCC > "" Then .BCC = sSendBCC
.Subject = sSubject
sTemp = "Hi Luke" & vbCrLf & vbCrLf
sTemp = sTemp & "The Quality ceritifcate has expired "
sTemp = sTemp & "for this supplier:" & vbCrLf & vbCrLf
' supplier name is in column F
sTemp = sTemp & " " & Cells(lRow, 6) & vbCrLf & vbCrLf
sTemp = sTemp & "Please take the appropriate "
sTemp = sTemp & "action." & vbCrLf & vbCrLf
sTemp = sTemp & "BR" & vbCrLf
.Body = sTemp
' Change the following to .Send if you want to
' send the message without reviewing first
.Display
End With
Set OutMail = Nothing
Cells(lRow, 23) = "S"
Cells(lRow, 24) = "E-mail sent on: " & Now()
End If
End If
Next lRow
Set OutApp = Nothing
End Sub
If anyone has any suggestions then I would be eternally grateful.
Thanks