none
Syncing Appointments on Quit of the Addin - OUTLOOK RRS feed

  • Question

  • Part of my application is to sync appointments between Outlook and My Database, Appointments created in outlook are saved to My Database at the point they are created, but I run a sync event within Outlook to do the same from My Database into Outlook.

    This was originally run on ThisAddIn Startup but as it can take a while to run and makes Outlook Start up take along time, I have moved it into ThisAddIn Quit.  The only problem with this is that I think Outlook has essentially closed whilst this code is running and I can't get access to the Appointment Object to create them.

    The reason I think this is this is the same code that has been running for the past 6 - 7 weeks in startup with no issues except speed, the day the quit change went live the errors started happening.  The user isn't aware, it's just on error I recieve an email.

    Thanks

    Thursday, April 26, 2012 8:57 AM

Answers

  • Something to bear in mind is that the Outlook product group is strongly discouraging developers from running code in quit events that takes time to execute.
     
    In some cases they are disabling addins that take too long to shut down, in some cases they just force a shutdown, and for VSTO addin the Addin_Shutdown() event will no longer fire as a result of OnDisconnection not firing. See http://blogs.msdn.com/b/rgregg/archive/2009/10/02/additional-shutdown-changes-for-outlook-2010-beta.aspx, and bear in mind that things only get stricter about shutdowns since Ryan posted that blog article.
     
    Background threads cannot use the Outlook object model at all. Redemption can be used if you instantiate an instance of RDOSession in the background thread and use NameSpace.MAPIOBJECT to set RDOSession.MAPIOBJECT in that thread. Extended MAPI can also run in the background, as Damian also indicated, but you need to take care that the background thread operation uses the same MAPI session that Outlook is using.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Vis Xero" <=?utf-8?B?VmlzIFhlcm8=?=> wrote in message news:19fd2769-6ee8-477c-9c48-007737feb1fa...

    As syncing currently 'locks' outlook up I'm only allowed to sync on events not at times users may be trying to use it. 

    Is there any other way of running background threads or is it only by using redemption?  I would have to get that cost authorised and we are trying to move away from 3rd party solutions due to past issues with regards to bugs and support.


    Ken Slovak MVP - Outlook
    Thursday, April 26, 2012 2:21 PM

All replies

  • i woudl rather use a timer or reminder to periodically synchronize. Or you could invest into redemption and using its RDO* objects, move whole work to backgrund thread.
    Thursday, April 26, 2012 10:12 AM
  • As syncing currently 'locks' outlook up I'm only allowed to sync on events not at times users may be trying to use it. 

    Is there any other way of running background threads or is it only by using redemption?  I would have to get that cost authorised and we are trying to move away from 3rd party solutions due to past issues with regards to bugs and support.

    Thursday, April 26, 2012 10:22 AM
  • sure there is - you can write your own code in C++ (reference source MFCMAPI).
    Thursday, April 26, 2012 10:47 AM
  • OK, thanks.  Are there any good sources/ tutorials that you know of that I could learn how to do this?
    Thursday, April 26, 2012 11:26 AM
  • no, not really. Look at the MFCMAPI source and remember that you will need only relatively small amout of code to do it.
    Thursday, April 26, 2012 12:04 PM
  • Something to bear in mind is that the Outlook product group is strongly discouraging developers from running code in quit events that takes time to execute.
     
    In some cases they are disabling addins that take too long to shut down, in some cases they just force a shutdown, and for VSTO addin the Addin_Shutdown() event will no longer fire as a result of OnDisconnection not firing. See http://blogs.msdn.com/b/rgregg/archive/2009/10/02/additional-shutdown-changes-for-outlook-2010-beta.aspx, and bear in mind that things only get stricter about shutdowns since Ryan posted that blog article.
     
    Background threads cannot use the Outlook object model at all. Redemption can be used if you instantiate an instance of RDOSession in the background thread and use NameSpace.MAPIOBJECT to set RDOSession.MAPIOBJECT in that thread. Extended MAPI can also run in the background, as Damian also indicated, but you need to take care that the background thread operation uses the same MAPI session that Outlook is using.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Vis Xero" <=?utf-8?B?VmlzIFhlcm8=?=> wrote in message news:19fd2769-6ee8-477c-9c48-007737feb1fa...

    As syncing currently 'locks' outlook up I'm only allowed to sync on events not at times users may be trying to use it. 

    Is there any other way of running background threads or is it only by using redemption?  I would have to get that cost authorised and we are trying to move away from 3rd party solutions due to past issues with regards to bugs and support.


    Ken Slovak MVP - Outlook
    Thursday, April 26, 2012 2:21 PM