outlook宏有条件地发送电子邮件

时间:2009-07-14 12:55:53

标签: vba outlook

任何人都可以指导我创建执行以下操作的Outlook宏: 每当我向特定的邮件ID发送邮件时,自动邮件将被发送到指定的组邮件-id或某些Outlook联系人组。

提前致谢!!

1 个答案:

答案 0 :(得分:1)

这是一个快速的VBA供您使用,将其添加到您的ThisOutlookSession模块中。

您应该能够通过工具菜单中的规则执行CC,或者编写代码来创建规则!

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    If Item.MessageClass = "IPM.Note" Then

        For Each myRecipient In Item.Recipients
             If myRecipient.Address = "<EMAIL ADDRESS TO FIND>" Then
                ''SendNotification
                SendNotificationWithCopy Item
             End If

        Next

    End If

End Sub


Sub SendNotification()
    Set objMail = Application.CreateItem(olMailItem)
    objMail.Recipients.Add "<EMAIL ADDRESS/GROUP TO SEND NOTIFICATION>"
    objMail.Recipients.ResolveAll
    objMail.Subject = "NOTIFICATION"
    objMail.Body = "Body Text"
    objMail.Send
End Sub



Sub SendNotificationWithCopy(obj As Object)

    Set objMail = Application.CreateItem(olMailItem)
    objMail.Recipients.Add "<EMAIL ADDRESS TO SEND NOTIFICATION>"
    objMail.Recipients.ResolveAll
    objMail.Attachments.Add obj, OlAttachmentType.olEmbeddeditem
    objMail.Subject = "NOTIFICATION with attachment"
    objMail.Body = "Body Text"
    objMail.Send
End Sub