Hello,
I am still new to the coding world and I could use some help. We are trying to set up outlook to automaticly scan the inbox for a specific subject line in an email. Once that has happend we need outlook to send an email stating that the email in question has been recieved or has not been recieved. This will be used to verify that emails dealing with reports have been sent out, now I have been able to set up outlook to send an auto email when it recieves the report email by using the rules in outlook. The problem I am having is setting outlook up to scan the inbox at a specific time and then send out a "Did not recieve" email if the report email does not come in. One of my co-workers sugested that I use this code and try to modify it to suite our needs, and this code works fine but it has to be run manualy and to only gives a pop up box. Any ideas? I am greatful for any help I can get.
Private Sub Application_Reminder(ByVal Item As Object)
If Item.Class = olTask Then
If InStr(Item.Subject, "subject") > 0 Then
ReminderUnreceivedMail
End If
End If
End Sub
Sub ReminderUnreceivedMail()
Dim Itms As Items
Dim srchSender As String
Dim srchSubject As String
Set Itms = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items
srchSender = "sender"
srchSubject = "xyz"
Set Itms = Itms.Restrict("[SenderName] = 'sender' And [Subject] = 'subject' And [SentOn] > '" & Format(Date, "yyyy-mm-dd") & "'")
If Itms.Count = 0 Then
MsgBox "No " & srchSubject & " email on " & Format(Date, "yyyy-mm-dd")
End If
Set Itms = Nothing
End Sub
I am still new to the coding world and I could use some help. We are trying to set up outlook to automaticly scan the inbox for a specific subject line in an email. Once that has happend we need outlook to send an email stating that the email in question has been recieved or has not been recieved. This will be used to verify that emails dealing with reports have been sent out, now I have been able to set up outlook to send an auto email when it recieves the report email by using the rules in outlook. The problem I am having is setting outlook up to scan the inbox at a specific time and then send out a "Did not recieve" email if the report email does not come in. One of my co-workers sugested that I use this code and try to modify it to suite our needs, and this code works fine but it has to be run manualy and to only gives a pop up box. Any ideas? I am greatful for any help I can get.
Private Sub Application_Reminder(ByVal Item As Object)
If Item.Class = olTask Then
If InStr(Item.Subject, "subject") > 0 Then
ReminderUnreceivedMail
End If
End If
End Sub
Sub ReminderUnreceivedMail()
Dim Itms As Items
Dim srchSender As String
Dim srchSubject As String
Set Itms = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items
srchSender = "sender"
srchSubject = "xyz"
Set Itms = Itms.Restrict("[SenderName] = 'sender' And [Subject] = 'subject' And [SentOn] > '" & Format(Date, "yyyy-mm-dd") & "'")
If Itms.Count = 0 Then
MsgBox "No " & srchSubject & " email on " & Format(Date, "yyyy-mm-dd")
End If
Set Itms = Nothing
End Sub