PC Review


Reply
Thread Tools Rate Thread

Addresses added by VB to calendar appointment don't work!

 
 
New Member
Join Date: Nov 2009
Posts: 1
 
      13th Nov 2009
I have several clients and e-mail accounts with each one that I'm forced to deal with. When I'm with a particular client I have to schedule a meeting -- however, the calendar in their outlook/exchange wouldn't be synchronized with my other calendars -- client2, and client3.

1. However, the calendar items created by this macro are not always "stable" soemtimes they show and then "cancel" by themselves, other times they just don't show -- even when everyone accepts them.

2. I get messages in my inboxe for every calendar item I create -- that just fills my in box, which didn't used to happen (before I wrote the macro) and created a calendar item and added addressees by hand.

I cut and pasted this VB macro from other macros on this and other sites. This Macro works about 70% of the time. I found that I had to set -- Item.MeetingStatus = olMeeting -- to get the Meeting item to save and feel as though there's something else VERY simple that I'm missing.

Any help would be greatly appreciated.

P.S. Do not fool around with ItemChange to do something similar to this -- the malestrom of messages nearly locked up my machine.


--- Start of code in ThisOutlookSession ---
Option Explicit
Public WithEvents MyOlItems As Outlook.Items
Public MyInProcess As Integer

Private Sub Initialize_Handler()
Set MyOlItems = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderCalendar).Items
End Sub

Private Sub Application_MAPILogonComplete()
'Initialize_Handler
End Sub

Private Sub Application_Startup()
Initialize_Handler
Debug.Print "*** Startup ***"
End Sub

Private Sub MyOlItems_ItemAdd(ByVal Item As Object)

'Exit if already processing a mail item
If MyInProcess Then Exit Sub
MyInProcess = -1

Debug.Print "* A -";
ProcessCalendarItem Item

MyInProcess = 0
End Sub


Private Function ProcessAddress(ByVal Item As Outlook.AppointmentItem, ByVal MyAddress As String) As

Integer
Dim MyRecipient As Recipient
Dim MyFlag As Integer

MyAddress = LCase(Trim(MyAddress))

'Search for my Address in the list of addressees -- check out SMTP
MyFlag = -1
For Each MyRecipient In Item.Recipients
If InStr(1, LCase(MyRecipient.AddressEntry), MyAddress) Then
MyFlag = 0
Exit For
End If
Next

'Add my Address to the list of addressees
If MyFlag Then
Item.Recipients.Add MyAddress
Item.MeetingStatus = olMeeting 'Have to add this to make the address take??
Item.Save
End If

ProcessAddress = MyFlag

End Function



Private Sub ProcessCalendarItem(ByVal Item As Object)

Dim MyFlag As Integer

If Item.Class <> olAppointment Then
Debug.Print Item.Class; " <-- Not Appointment Item"
Exit Sub
End If

Debug.Print Item.Recipients.Count

MyFlag = ProcessAddress(Item, "(E-Mail Removed)")
MyFlag = MyFlag + ProcessAddress(Item, "(E-Mail Removed)")
MyFlag = MyFlag + ProcessAddress(Item, "(E-Mail Removed)")
MyFlag = MyFlag + ProcessAddress(Item, "(E-Mail Removed)")

If MyFlag Then Item.Send

End Sub
--- End of code ---
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can you tell when an appointment was added to calendar? mhb Microsoft Outlook Calendar 1 14th Jan 2009 06:16 PM
How do I prevent an appointment from being added to my calendar v. MikeKiserLaw Microsoft Outlook Calendar 1 12th Jan 2009 01:58 PM
see who added appointment to group calendar Barb Microsoft Outlook Calendar 2 24th May 2008 01:40 AM
How can I tell who added an appointment on my calendar? =?Utf-8?B?V2lzaGZ1bA==?= Microsoft Outlook Calendar 0 22nd Feb 2005 02:21 AM
How can I see who added an appointment to a calendar? =?Utf-8?B?S3Jpc3R5?= Microsoft Outlook Calendar 1 13th Oct 2004 01:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:19 AM.