BUG: Outlook: Error thrown by Outlook 2007 when all attendees of a meeting are removed programmatically before sending it
THIS IS JUST FYI AND IF YOU ARE FACING THE SIMILAR ISSUE THEM PLEASE LET ME KNOW. WE ARE AWARE OF THIS ISSUE AND ALREADY WORKING ON A FIX FOR THE SAME.
When using Outlook UI if a user tries to send a meeting request without any recipient he is prompted by the following prompt
"The meeting cannot be sent because there are no recipient names in the To box. Would you like to save and close this meeting instead?" - Yes/No
..but if you try to send the meeting programmatically using Outlook 2007 SP2 , you will not get the same prompt but gets this error message
"Out of memory or system resources. Close some windows or programs and try again."
Although this works fine on all other versions like Outlook 2003, 2007 SP1, & 2010 except Outlook 2007 SP2. In all other versions the meeting is saved locally as Appointment instead.
CODE TO REPRODUCE THE BUG & WORKAROUND (SEE CODE COMMENTS)
Dim WithEvents oInspectors As Inspectors
Dim WithEvents oItem As AppointmentItem
Sub Init()
Set oInspectors = Application.Inspectors
End Sub
Private Sub oInspectors_NewInspector(ByVal Inspector As Inspector)
If TypeName(Inspector.CurrentItem) = "AppointmentItem" Then
Set oItem = Inspector.CurrentItem
End If
End Sub
Private Sub oItem_Write(Cancel As Boolean)
For i = oItem.Recipients.Count To 1 Step -1
oItem.Recipients.Remove (i)
Next
'If we leave the Cancel = False then we get the error message
' Workaround Code:
' This will emulate the way Outlook does it in other versions by Saving the appointment to local calendar
If oItem.Recipients.Count = 0 Then
Cancel = True
oItem.Close olSave
End If
End Sub