none
syncing of conatcts with online database as background process at outlook 2007 addin startup RRS feed

  • Question

  • I've created addin for outlook 2007 (also for outlook 2010) using vsto,C#. This addin syncs all contacts in default personal folder with online database at the startup process of addin. Well as this executes actively, we can't work with other parts of outlook until it get completes.

    Now I need to execute this process passively that is when this executes - executes at background, so that we can work with other non-contact items like calendars, appointments, mails etc.

    will it be possible, if yes, then can you give me some idea regarding code - well during this process , the user should not be allowed to work with items related to contacts, like opening/saving/viewing contact items etc.

    Any help would be appreciated much.

    Thanks

    --Mehnaz

     

     

    Wednesday, April 6, 2011 9:20 AM

Answers

  • RDO is another way of referring to Redemption (www.dimastr.com/redemption). Redemption is a COM dll that wraps Extended MAPI in a library that's object oriented, can be used from managed code, and can be used in background threads safely.
     
    As a reference on Microsoft's view of using the Outlook object model from a background thread see http://msdn.microsoft.com/en-us/library/dd278301.aspx.
     
    One of the advantages of using Redemption (RDO) in a background thread (aside from it being supported) is that you can still work in the main Outlook thread. So the user interface doesn't get hung at all. In an addin I just finished for Outlook 2010 using RDO we're synching/downloading/updating over 1200 contact items in one background process, and the user interface remains responsive.
     
    What you do to set this up is to instantiate an RDOSession (MAPI session) in the main thread:
     
    Redemption.RDOSession session = new Redemption.RDOSession;
    session.MAPIOBJECT = ns.MAPIOBJECT // ns == NameSpace object
     
    Then in any background threads you instantiate another RDOSession and pass it the MAPIOBJECT from the main thread so all sessions are using the same MAPI logon and session.
     
    There are samples and other information at the Redemption Web site, and more specifically on the RDO set of objects at www.dimastr.com/redemption/rdo.
     

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Mehnaz13" <=?utf-8?B?TWVobmF6MTM=?=> wrote in message news:b44703c0-78a1-4ab6-a49f-3dabe963a871...

    Hi Ken/Helmut,

    well actually I read all discussions between both of you, I'm still not highly experienced in outlook-vsto programming, right now yes, while sync process executes , I display in other form showing sync process progress and user have to wait - until it completes.

    but my client requirement is that we should execute this process in background so that he can do other work of outlook meanwhile. In the past I was going to write some code using threads or something but seems to be complex so left, but well now I've to do it again,

    Ken, I'm not asking for the whole code, but instead some help links /some code , as you used terminology RDO, I'll google it, but If you can help more, will be thankful to you.

    second, If I get success to execute this process in the background , then still I'll have to limit the user not to work with contacts, I had also idea that set some global variable and in the addin.cs file if contacts load I close them thorugh code or any other way, I'll have to look for/test.

    As you told you have written addin , do you think, this will be possible.

    Also whatever the code we write, we have to make sure that outlook will not crash.

    Thanks

    --Mehnaz

     


    Ken Slovak MVP - Outlook
    • Marked as answer by Mehnaz13 Friday, April 8, 2011 4:02 AM
    Thursday, April 7, 2011 1:13 PM

All replies

  • Hello Menaz,

    i've dome similar AddINs in the past, so yes - I would say it's possible.
    I'm using a BackgroundWorker (not recommended by Microsoft) to get the ContactFolder Table and then see wich Items has been change since last Update (sppeds up everything) and sync them via a Webservice to a Server.

    The other part (disalowing to Update Contacts while syncing is not a good Idea. I think you cant do that.
    You can try it using a global variable and an Inspector/Wrapper - but I think it's not possible at all.

    What you can do is to open a Modal form that displays the Sync-Progress. Then the User can't go back to Outlook and do anything until the Sync has been finnished.

    Feel free to contact me offline if you want a prototype

    Greets - Helmut


    Helmut Obertanner [http://www.x4u.de] [http://www.outlooksharp.de]
    Wednesday, April 6, 2011 11:38 AM
    Answerer
  • Hi Helmut,
     
    I don't know that I'd recommend using the OOM from a background worker, not unless the user was running no other Outlook addins or code to hang or crash. That way at least any crashes will be blamed where they belong, at the code running the OOM in a background process. I think I'd recommend using Redemption instead of RDO in this case, I've used that in this way many times with no effect on Outlook or other code.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Helmut Obertanner" <=?utf-8?B?SGVsbXV0IE9iZXJ0YW5uZXI=?=> wrote in message news:f993b2ed-8bff-43b8-a62e-948e36c752e6...

    Hello Menaz,

    i've dome similar AddINs in the past, so yes - I would say it's possible.
    I'm using a BackgroundWorker (not recommended by Microsoft) to get the ContactFolder Table and then see wich Items has been change since last Update (sppeds up everything) and sync them via a Webservice to a Server.

    The other part (disalowing to Update Contacts while syncing is not a good Idea. I think you cant do that.
    You can try it using a global variable and an Inspector/Wrapper - but I think it's not possible at all.

    What you can do is to open a Modal form that displays the Sync-Progress. Then the User can't go back to Outlook and do anything until the Sync has been finnished.

    Feel free to contact me offline if you want a prototype

    Greets - Helmut


    Helmut Obertanner [http://www.x4u.de] [http://www.outlooksharp.de]

    Ken Slovak MVP - Outlook
    Wednesday, April 6, 2011 1:04 PM
  • Hi Ken,

    from my point of view it depends on how you use the OOM.
    It's the same when you automate Outlook from another Process - this works the same way.
    My expirience is, that you must not pass Object references between threads. As long as you create the Objects inside a thread and safely clean up the references in this thread all goes well.
    I just pass EntryIds/FolderID's between Threads.

    And - if Outlook shuts down you need to stop the workerthread gracefully.

    But - that's just my expirience.

    Maybe there's a difference when you use a shared COM dll. Because there you are in the same appdomain.

    Greets - Helmut


    Helmut Obertanner [http://www.x4u.de] [http://www.outlooksharp.de]
    Wednesday, April 6, 2011 1:14 PM
    Answerer
  • Well, all my shared addins use shimming for an isolated AppDomain, so I don't know that it's any different than using VSTO for that. And hte MS docs don't differentiate, they just say using OOM in background threads is not supported. So I'd say we'd have to agree to differr on this, I'd be using Redemption and not using OOM there.
     
    I just finished a VSTO 4 addin for Outlook 2010 where we're doing background downloading and synching of contacts, that's using RDO for that after the original author ran into problems with the OOM use from a separate STA thread he set up. I rewrote the entire addin to do all they synching with RDO and a background worker instead.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Helmut Obertanner" <=?utf-8?B?SGVsbXV0IE9iZXJ0YW5uZXI=?=> wrote in message news:015e3592-286d-4a6c-bcc9-d17093b7c1d5...

    Hi Ken,

    from my point of view it depends on how you use the OOM.
    It's the same when you automate Outlook from another Process - this works the same way.
    My expirience is, that you must not pass Object references between threads. As long as you create the Objects inside a thread and safely clean up the references in this thread all goes well.
    I just pass EntryIds/FolderID's between Threads.

    And - if Outlook shuts down you need to stop the workerthread gracefully.

    But - that's just my expirience.

    Maybe there's a difference when you use a shared COM dll. Because there you are in the same appdomain.

    Greets - Helmut


    Helmut Obertanner [http://www.x4u.de] [http://www.outlooksharp.de]

    Ken Slovak MVP - Outlook
    Wednesday, April 6, 2011 2:05 PM
  • Hi Ken/Helmut,

    well actually I read all discussions between both of you, I'm still not highly experienced in outlook-vsto programming, right now yes, while sync process executes , I display in other form showing sync process progress and user have to wait - until it completes.

    but my client requirement is that we should execute this process in background so that he can do other work of outlook meanwhile. In the past I was going to write some code using threads or something but seems to be complex so left, but well now I've to do it again,

    Ken, I'm not asking for the whole code, but instead some help links /some code , as you used terminology RDO, I'll google it, but If you can help more, will be thankful to you.

    second, If I get success to execute this process in the background , then still I'll have to limit the user not to work with contacts, I had also idea that set some global variable and in the addin.cs file if contacts load I close them thorugh code or any other way, I'll have to look for/test.

    As you told you have written addin , do you think, this will be possible.

    Also whatever the code we write, we have to make sure that outlook will not crash.

    Thanks

    --Mehnaz

     

    Thursday, April 7, 2011 12:04 PM
  • RDO is another way of referring to Redemption (www.dimastr.com/redemption). Redemption is a COM dll that wraps Extended MAPI in a library that's object oriented, can be used from managed code, and can be used in background threads safely.
     
    As a reference on Microsoft's view of using the Outlook object model from a background thread see http://msdn.microsoft.com/en-us/library/dd278301.aspx.
     
    One of the advantages of using Redemption (RDO) in a background thread (aside from it being supported) is that you can still work in the main Outlook thread. So the user interface doesn't get hung at all. In an addin I just finished for Outlook 2010 using RDO we're synching/downloading/updating over 1200 contact items in one background process, and the user interface remains responsive.
     
    What you do to set this up is to instantiate an RDOSession (MAPI session) in the main thread:
     
    Redemption.RDOSession session = new Redemption.RDOSession;
    session.MAPIOBJECT = ns.MAPIOBJECT // ns == NameSpace object
     
    Then in any background threads you instantiate another RDOSession and pass it the MAPIOBJECT from the main thread so all sessions are using the same MAPI logon and session.
     
    There are samples and other information at the Redemption Web site, and more specifically on the RDO set of objects at www.dimastr.com/redemption/rdo.
     

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Mehnaz13" <=?utf-8?B?TWVobmF6MTM=?=> wrote in message news:b44703c0-78a1-4ab6-a49f-3dabe963a871...

    Hi Ken/Helmut,

    well actually I read all discussions between both of you, I'm still not highly experienced in outlook-vsto programming, right now yes, while sync process executes , I display in other form showing sync process progress and user have to wait - until it completes.

    but my client requirement is that we should execute this process in background so that he can do other work of outlook meanwhile. In the past I was going to write some code using threads or something but seems to be complex so left, but well now I've to do it again,

    Ken, I'm not asking for the whole code, but instead some help links /some code , as you used terminology RDO, I'll google it, but If you can help more, will be thankful to you.

    second, If I get success to execute this process in the background , then still I'll have to limit the user not to work with contacts, I had also idea that set some global variable and in the addin.cs file if contacts load I close them thorugh code or any other way, I'll have to look for/test.

    As you told you have written addin , do you think, this will be possible.

    Also whatever the code we write, we have to make sure that outlook will not crash.

    Thanks

    --Mehnaz

     


    Ken Slovak MVP - Outlook
    • Marked as answer by Mehnaz13 Friday, April 8, 2011 4:02 AM
    Thursday, April 7, 2011 1:13 PM
  • Hi Ken,

     

    Thanks for the prompt responses, I'll start  work on it, if get some problem , will be asking in the same thread or will raise new question.

    --Mehnaz

    Friday, April 8, 2011 4:02 AM