none
Get the account an outlook 2003 mail/store is connected to

    Question

  • Hi All,

    I am creating an add-in for Outlook 2003. In it, I am creating a store (pst) for holding some custom mail and now have a requirement to do a process when a mail is copied/moved into a subfolder in my PST from another outlook pst. My problem is, for that process I want to find the account that that email originated from.

    Let me explain the scenario with an example:

    Assume the user has 2 outlook mail accounts setup on their Outlook 2003 instance. One for their office email (say, john.doe@company.com - name: "John Doe"), and their personal mail account (say jdoe@live.mail.com - name: "**John**"). That would show them two store objects on their Outlook explorer - say "compStore" and "liveStore" respectively. The default account is the company account.

    Now they install my add-in and it creates another store - "myStore".

    If the user were to copy a mail item from the liveStore's inbox or sent items, and pasted it into a folder in myStore, I want to be able to get the originating store's connected email - in this case jdoe@live.mail.com - and the user name - "**John**" - from my code.

    I am capturing the paste event using the "BeforeItemPaste" event of the explorer. NameSpace.CurrentUser always returns the default account credentials. Can this be done?

    In the event it cannot, I am happy to let the user select which account he wants to have the mails originating from, if I can expose a list of the accounts he has in a custom winForm control. Is there a way to get a list of the accounts?

    Thimila H. Fernando

    Tuesday, February 26, 2013 8:36 AM

Answers

  • In Outlook 2010 or 2013, you could use MailItem.Account, then Account.DeliveryStore to figure out where the account delivers to,

    In the older versions of Outlook, you can use Redemption - RDOMail.Account will return the RDOAccount object, then you can use RDOPOP3Account.DeliverToStore or RDOIMAPAccount.Store or RDOHTTPAccount.Store or RDOExchangeAccount.PrimaryStore (depending on the account type).


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

    Tuesday, February 26, 2013 2:39 PM

All replies

  • In Outlook 2010 or 2013, you could use MailItem.Account, then Account.DeliveryStore to figure out where the account delivers to,

    In the older versions of Outlook, you can use Redemption - RDOMail.Account will return the RDOAccount object, then you can use RDOPOP3Account.DeliverToStore or RDOIMAPAccount.Store or RDOHTTPAccount.Store or RDOExchangeAccount.PrimaryStore (depending on the account type).


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

    Tuesday, February 26, 2013 2:39 PM
  • Thanks Dimitry,

    I got the RDOMail.Account, cast it to its relevant account type, and checked the UserName and POP3_UserName/IMAP_UserName properties.

    One question, isn't the RDOExchangeAccount interface available on older versions of Redemption - say 4.5.0.812?

    Wednesday, February 27, 2013 7:13 AM
  • No, RDOExchangeAccount  was added in version 5.4 - see http://www.dimastr.com/redemption/history.htm

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

    Thursday, February 28, 2013 9:18 PM
  • Thanks Dmitry!
    Monday, March 04, 2013 1:10 AM