Outlook 2010规则在特定时间转发带附件的电子邮件

时间:2015-04-08 16:05:55

标签: vba email outlook outlook-vba

每天,我会收到包含附件的每小时电子邮件,并且主题格式为2014-02-13 emailAlert

是否有规则/ VBA我可以forwardwith attachment这封电子邮件everyday自动specific time发送给某人newest

它应仅在该特定时间点转发主题为emailAlert的{​​{1}}电子邮件。

感谢您的帮助: - )

1 个答案:

答案 0 :(得分:0)

您可以在Outlook中创建规则,然后分配VBA宏以在符合条件的情况下转发收到的电子邮件。宏sub应如下所示:

public sub test(mail as MailItem)
  ' do whatever you need here
end sub

邮件对象代表收到的电子邮件。

MailItem类的Forward方法为项执行Forward操作,并将生成的副本作为MailItem对象返回。例如,以下示例说明了如何使用Forward方法:

Sub RemoveAttachmentBeforeForwarding()  
  Dim myinspector As Outlook.Inspector  
  Dim myItem As Outlook.MailItem  
  Dim myattachments As Outlook.Attachments 

  Set myinspector = Application.ActiveInspector  
  If Not TypeName(myinspector) = "Nothing" Then  
    Set myItem = myinspector.CurrentItem.Forward  
    Set myattachments = myItem.Attachments   
    While myattachments.Count > 0  
      myattachments.Remove 1  
    Wend  
    myItem.Display  
    myItem.Recipients.Add "Eugene Astafiev"  
    myItem.Send  
  Else  
    MsgBox "There is no active inspector."  
  End If 
End Sub

MailItem类的DeferredDeliveryTime属性允许设置一个日期,指示邮件传递的日期和时间。

最后,您可能会发现Getting Started with VBA in Outlook 2010文章很有帮助。