I am trying to write some basic Outlook code that should support Outlook 2003, 2007 and 2010. I am working with Outlook 2010 PIAs. Everything works except a method that should cause Outlook to perform Send/Receive. I have tried a couple of options:
- Call Namespace.SendAndReceive method (works on Outlook 2007 and 2010, fails on Outlook 2003 with AccessViolationException).
- Iterate through Namespace.SyncObjects and calling their start method (works in Outlook 2003 and 2007 and fails on Outlook 2010 with RPC server is not available when I try to call GetNamespace(“MAPI”) on my application object)
Can someone propose a method that should work consistently on all versions?
I believe that
SendAndReceive()was added as a convenience method in 2007 so that won’t work in 2003 as you found out. According to the 2010 documentation you should still be able to useSyncObjectscollection and still callStart(). Is it possible that you’re 2010 installation has a bad mail/news/whatever profile? IsStart()failing on a specificSyncObject?The other solution which you probably already thought of is to use
SyncObjectsfor 2003 andSendAndReceive()for future versions.