none
Create and write to PST without outlook RRS feed

  • Question

  • The code i have uses a single outlook profile to create and write to 10 PSTs at a time.

    The problem is that to release a completed PST outlook needs to be restarted so restarting outlook interrupts all 10 sessions

    I have 2 possible options

    1. Develop a method that will open 10 sessions of outlook. This doesnt appear possible without creating 10 logon sessions to a server. I could use Runas and extraoutlook but how would i reference the mapi namespace for each instance?

    2. Create and write to the PST without outlook. Is this even possible?

    Appreciate any assistance/ideas

    Tuesday, April 29, 2014 5:37 PM

Answers

All replies

  • Hello, Only one instance of Outlook is possible. The structure of pst files is described at http://msdn.microsoft.com/en-us/library/gg615595(v=office.14).aspx . Also you may find helpful http://pstviewtool.codeplex.com . You can find commercial tools for working with pst files without Outlook. Do you release underlying COM objects instantly? What code do you use for working with stores in Outlook?
    Tuesday, April 29, 2014 7:15 PM
  • All of my code is in powershell

    I'm hooking in to outlook with....
    $script:objOutlook = new-object -com Outlook.Application
    $script:objNameSpace = $script:objOutlook.GetNamespace("MAPI")

    Add the pst with.....
    objNameSpace.addstore($pstname)

    Is outlook running and pst added. Open if not. Check if the target folder exists. If not create it.

    Is outlook running and pst added. Open if not. Save the email item to the target folder.

    Loop until all email is source file saved to pst.

    Disconnect the PST

    Outlook needs to restart here but if 10 sessions are running all are stopped and the outlook recovery routine kicks in. Sometimes it recovers. sometimes it doesnt but its the same code that initiates outlook the first time round so why would it fail. I need to debug....

    Tuesday, April 29, 2014 8:29 PM
  • You will need to make sure that the process that opens the PST file exits to prevent the PST file from being locked.

    You can either use Extended MAPI (C++ or Delphi) or Redemption (any language). In the latter case, you can use RDOSession.LogonPstStore or RDOSession.Stores.AddPstStore.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, April 29, 2014 10:57 PM
  • I thought redemption also used outlook to hook in to the pst?
    Wednesday, April 30, 2014 5:50 PM
  • No, Redemption uses Extended MAPI - it loads the MAPI dlls in-proc, but it does not load outlook.exe, at least not unless MAPI itself loads outlook.exe - e.g. when you call RDOMail.Display and the MAPI system invokes the MAPI form implemented by outlook.exe.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, April 30, 2014 5:55 PM
  • You shouldn't use Outlook in that case. Try using a low level approach - Extended MAPI or any other commercial tool for getting the job done.
    Thursday, May 1, 2014 11:50 AM