none
Retrieving Default Mail Account RRS feed

  • Question

  • I am using Interop.Outlook to send my emails through my application and everything is working fine.

    I received a request that a user wants to email from a different account setup in Outlook. So basically he has one exchange email and one internet email. I want to return the email address that is set as default in Outlook and use that address to email out. So basically when the user sets his Exchange Account to be his default account, the emails must be sent out using that account, and when he sets his internet email to his default email address, the emails must be sent using that account.

    Is there a way to establish which account is set as the Default Email Account in Outlook? 

    Wednesday, February 20, 2013 3:08 PM

Answers

  • OK, so the only solution I could find is that the user must go and create a new Mail Profile. So every time he opens outlook he needs to specify which profile he wants to use and my program sends it automatically using the Primary Email Address setup on that specific profile.
    • Marked as answer by Dougie011 Thursday, February 21, 2013 10:59 AM
    Thursday, February 21, 2013 10:59 AM

All replies

  • You can use the Namespace.Accounts collection in Outlook: http://msdn.microsoft.com/en-us/library/office/ff867142.aspx

    If you want a more granular control, you can use RDOSession.Accounts collection in Redemption, which exposes RDOAccounts.GetOrder method - http://www.dimastr.com/redemption/RDOAccounts.htm


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

    Wednesday, February 20, 2013 3:13 PM
  • I am using the accounts namespace, but I can't seem to find which account is set as the default account on the namespace?


    • Edited by Dougie011 Thursday, February 21, 2013 8:24 AM
    Thursday, February 21, 2013 6:44 AM
  • OK, so the only solution I could find is that the user must go and create a new Mail Profile. So every time he opens outlook he needs to specify which profile he wants to use and my program sends it automatically using the Primary Email Address setup on that specific profile.
    • Marked as answer by Dougie011 Thursday, February 21, 2013 10:59 AM
    Thursday, February 21, 2013 10:59 AM
  • Session object has DefaultStore property - you can compare it with Account's DeliveryStore to see which one is default.
    Thursday, February 21, 2013 11:07 AM
  • That would not work if, for example,  you have multiple POP3/SMTP accounts all delivering to the same PST store

    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 21, 2013 1:22 PM
  • i forgot about that scenario, so no hope?

    Thursday, February 21, 2013 1:37 PM
  • If you want the default sending account for the Outlook profile, create a new mail item and check SendUsingAccount, for example this Outlook VBA snippet would give the name:
     
    Dim oMail As Outlook.MailItem
    Set oMail = Application.CreateItem(olMailItem)
    Debug.Print oMail.SendUsingAccount.DisplayName

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "DamianD" <=?utf-8?B?RGFtaWFuRA==?=> wrote in message news:e98be5f2-b0a1-4e7d-8d00-d10a3c218d4e...

    i forgot about that scenario, so no hope?


    Ken Slovak MVP - Outlook
    Thursday, February 21, 2013 2:44 PM
    Moderator