检查是否未收到电子邮件 [英] Check if an email has NOT been received

查看:76
本文介绍了检查是否未收到电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我每个工作日都会收到两次电子邮件报告.有时,发送这些报告的机器会崩溃,并且没有发送电子邮件.我想要做的是使用一些 Outlook VBA 检查电子邮件是否在 12:15 和 17:05 到达.

I receive an email report twice every workday. Sometimes the machine that sends these reports crashes and no emails are sent out. What I am wanting to do is use some Outlook VBA to check if an email hasnt arrived at 12:15 and 17:05.

查找存在的电子邮件相当容易,但查找不存在的电子邮件让我有点摸不着头脑.我现在设置了一个班级模块(我认为这是要走的路),如果没有收到电子邮件,我有我想做的事情的代码,但不知道如何去检查电子邮件那些时候.这可能很简单,但之前没有在 Outlook VBA 中真正编写过脚本,所以不知道从哪里开始.

Finding an email that is there is fairly easy, but finding one that isnt is making me scratch my head a bit. I have a class module set up right now (I assume that would be the way to go) and have the code for what I want to do if no email has been received, but cannot figure out how to go about checking for the email at those times. It might be something simple, but have not really scripted in Outlook VBA before, so am not sure where to start.

推荐答案

评论中指出的方法.

Outlook VBA - 每半小时运行一次代码

展望VBA - 使用 Outlook 2010 64 位每半小时运行一次代码

一个可能更简单的替代方案.设置带有提醒的重复任务.

A possibly simpler alternative. Set a recurring task with a reminder.

在这个OutlookSession中

In ThisOutlookSession

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 = "subject"

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

这篇关于检查是否未收到电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆