Running Office 2003 on WinXP SP3.
I have this VBA, it runs without error, but only manually. I want it run automaticaly when Outlook 2003 is started every time a Contact is changed. Maybe I stuck it in the wrong place? In the Microsoft Visual Basic Editor I have:
Project 1
-Microsoft Office Outlook Objects
-ThisOutlookSession
myContacts ItemChange
Public WithEvents myContacts As Items
Public Sub Initialize_myContacts()
Set myContacts = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts).Items
End Sub
Private Sub myContacts_ItemChange(ByVal Item As Object)
Dim ContactUpdateMessage As MailItem
If MsgBox("Notify the office of this contact change?", vbYesNo + vbQuestion, "Contact Data Changed") = vbYes Then
Set ContactUpdateMessage = Application.CreateItem(ItemType:=olMailItem)
With ContactUpdateMessage
.To = "Office"
.Subject = "Contact Detail Change: " & Item.Subject
.Body = "The following contact has changed: " & vbCr & cbCr & Item.Subject
.Attachments.Add Source:=Item, Position:=50
.Send
End With
End If
End Sub
Also when I tested it, I used my email address in the .To line. As I said it ran without error, Clicking the Save and Close button creates a duplicate entry in My Contacts instead of overwriting the original. Does anyone know why that happens?
Thank you for your time.
Evil8
I have this VBA, it runs without error, but only manually. I want it run automaticaly when Outlook 2003 is started every time a Contact is changed. Maybe I stuck it in the wrong place? In the Microsoft Visual Basic Editor I have:
Project 1
-Microsoft Office Outlook Objects
-ThisOutlookSession
myContacts ItemChange
Public WithEvents myContacts As Items
Public Sub Initialize_myContacts()
Set myContacts = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts).Items
End Sub
Private Sub myContacts_ItemChange(ByVal Item As Object)
Dim ContactUpdateMessage As MailItem
If MsgBox("Notify the office of this contact change?", vbYesNo + vbQuestion, "Contact Data Changed") = vbYes Then
Set ContactUpdateMessage = Application.CreateItem(ItemType:=olMailItem)
With ContactUpdateMessage
.To = "Office"
.Subject = "Contact Detail Change: " & Item.Subject
.Body = "The following contact has changed: " & vbCr & cbCr & Item.Subject
.Attachments.Add Source:=Item, Position:=50
.Send
End With
End If
End Sub
Also when I tested it, I used my email address in the .To line. As I said it ran without error, Clicking the Save and Close button creates a duplicate entry in My Contacts instead of overwriting the original. Does anyone know why that happens?
Thank you for your time.
Evil8