2015-04-03 88 views
0

我需要一个展望宏,做如下的逻辑:(VBA在OUTLOOK)检查,如果电子邮件尚未收到VBA

  • 9:00之间每个工作日至10:00在检查特定文件夹,如果从那天起有任何电子邮件。
  • 如果没有电子邮件,请发送简单的邮件给特定的人。

非常感谢。

+0

您可能会发现http://stackoverflow.com/help有用。编辑问题以添加详细信息。如果无法打捞,请考虑删除此问题。目前它只能收集影响你提问的能力。 http://meta.stackoverflow.com/questions/258757/how-can-i-understand-why-am-i-receiving-a-warning-that-i-could-be-blocked – niton 2015-04-03 14:58:51

回答

0

每个工作日上午9点到上午10点之间检查特定文件夹,如果有任何电子邮件,从那天起。

您需要运行计时器以定期运行任务。有关更多信息,请参阅Outlook VBA - Run a code every half an hour。使用Items类的Find/FindNext或Restrict方法来查找符合条件的Outlook项目。

如果没有电子邮件,请发送简单的邮件给特定的人。

如果没有找到项目,请参阅#1,您可以创建并提交邮件项目。

 ' Create the message. 
     Set objOutlookMsg = objOutlook.CreateItem(olMailItem) 

     With objOutlookMsg 
      ' Add the To recipient(s) to the message. 
      Set objOutlookRecip = .Recipients.Add("Nancy Davolio") 
      objOutlookRecip.Type = olTo 

      ' Add the CC recipient(s) to the message. 
      Set objOutlookRecip = .Recipients.Add("Michael Suyama") 
      objOutlookRecip.Type = olCC 

     ' Add the BCC recipient(s) to the message. 
      Set objOutlookRecip = .Recipients.Add("Andrew Fuller") 
      objOutlookRecip.Type = olBCC 

     ' Set the Subject, Body, and Importance of the message. 
     .Subject = "This is an Automation test with Microsoft Outlook" 
     .Body = "This is the body of the message." &vbCrLf & vbCrLf 
     .Importance = olImportanceHigh 'High importance 

     ' Resolve each Recipient's name. 
     For Each ObjOutlookRecip In .Recipients 
      objOutlookRecip.Resolve 
     Next 

     .Save 
     .Send 
     End With 
相关问题