View Single Post
  #2  
Old May 27th 09, 10:04 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Outlook become non responsive if i write outlook item in bulk

Just a tip, with those nested IIF's that code will be a real mess to debug.
I'd unwrap it into a set of if blocks to make debugging easier. BTW, that is
Outlook object model code, not Simple MAPI API calls.

Define "many items in bulk" (how many, show the code to create them), define
"behaves inconsistently".

Always mention the Outlook and Window versions, and store type (PST files,
Exchange, etc.).

Do you get any exceptions? Set up try...catch blocks to trap any errors.

Don't use multiple dot operators, especially in loops. Declare your object
variables outside the loop avoid implicitly created objects that cannot be
released. For example:

Dim colItems As Outlook.Items = MyFolder.Items
olitem = colItems.Add(olType)

That way the Items collection can explicitly be released. That's especially
important in loops and hugely so with Exchange, where there's an RPC channel
limit. Exceeding that limit will cause exceptions, and implicitly created
objects all use up RPC channels and can't be released.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Ashish" Ashish @discussions.microsoft.com wrote in message
...
Hi
I write outlook item using the simple MAPI api .
Following is the code example.
Dim MyFolder As Microsoft.Office.Interop.Outlook.MAPIFolder
Dim MyFileName As String
Dim OlType As Microsoft.Office.Interop.Outlook.OlItemType
Dim TypeSuffix As String
Dim olitem as object
OlType = GetCorrespondingOlItemType(CalType)
TypeSuffix = GetCorrespondingSuffix(CalType)
MyFolder = IIf(OlType =
Microsoft.Office.Interop.Outlook.OlItemType.olTask Item, mobjTaskMAPIFld,
IIf(OlType =
Microsoft.Office.Interop.Outlook.OlItemType.olAppo intmentItem,
mobjApptMAPIFld, mobjContactMAPIFld))

On Error GoTo OpenAsDefault
Err.Clear()
olitem= MyFolder.Items.Add(OlType)
olitem.save
System.Runtime.InteropServices.Marshal.FinalReleas eComObject(olitem)

if a write many items in bulk, the oulook behaves inconsistently,
Even if i create a new contact manually and update it, lastmodification
time
property will not get updated.

Though this issue is not consistenly reporducible, can some help me
finding
any reason why this is happening ?

Thanks in advance.

Best Regards
Ashish Rawat


Ads