views:

771

answers:

1

Hi, Could anyone guide me in creating an Outlook Macro that does the following: Whenever I send a mail to a particular mail-id an automated mail will be send to a specified group pa mail-ids or some outlook contacts group.

Thanks in advance!!

A: 

Here is a quick piece of VBA for you to get going with, add it in your ThisOutlookSession module.

you should be able to do the CC via a rule as well from the tools menu, or write the code to create a rule !

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
76mel