none
Setting Outlook's Default mailbox programaticaly C# Microsoft Outlook Library 14.0 RRS feed

  • Question

  • I want to set the user selected domain(from list of domains configured in Outlook) from my application as Outlook's Default mailbox programaticaly. Is there any function in outlook library 14.0 to set default mailbox from all configured outlook accounts ?

    I am using C# and Microsoft Outlook Library 14.0 for Outlook 2010 for my application.
    Saturday, May 2, 2015 3:15 AM

Answers

  • Hello Sridhar,

    The Outlook object model doesn't provide anything for setting the default account in Outlook. These settings are stored in the windows registry. The How do I get Outlook to actually default new emails to a specific account and not ignore the default setting? forum thread states the following:

    Out of the box, Outlook 2010 SP1 and Outlook 2013 use the default account for Send to commands but not for new messages created while viewing a pst file (when a POP account is assigned to the pst file), unless you set a registry value to always force the use of the default account.

    To force all new messages to use the default email account, regardless of which pst file you are viewing, browse to the following registry subkey in Outlook 2010 and add a DWORD named NewItemsUseDefaultSendingAccount:

    HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Options\Mail
    DWORD value: NewItemsUseDefaultSendingAccount
    Value: 1
    

    In Outlook 2013, the key is:

    HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\Options\Mail
    DWORD value: NewItemsUseDefaultSendingAccount
    Value: 1
    

    Registry key to force account selection every time

    This fix is simple, but can get annoying, fast, since it forces the user to select an account every time they send a new message. (Replies and Forwards always use the account the message arrived on.)

    This might be good for people who use multiple accounts and frequently (accidentally) send using the wrong account, especially if they are sending sensitive documents, as it will almost eliminate accidentally sending email from the wrong account.

    HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\14.0\outlook\options
    Value Name: ForceAccountSelection
    Value type: REG_DWORD: 1 for force, 0 to disable.
    

    In Outlook 2013, the registry key is:

    HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\15.0\outlook\options
    Value Name: ForceAccountSelection
    Value type: REG_DWORD: 1 for force, 0 to disable.

    Also see Outlook 2010 does not honor the default sending account .

    You may also find the SendUsingAccount property of the MailItem class which allows to set an Account object that represents the account under which the MailItem is to be sent. For example:

    Sub SendUsingAccount() 
     Dim oAccount As Outlook.account 
     For Each oAccount In Application.Session.Accounts 
     If oAccount.AccountType = olPop3 Then 
      Dim oMail As Outlook.MailItem 
      Set oMail = Application.CreateItem(olMailItem) 
      oMail.Subject = "Sent using POP3 Account" 
      oMail.Recipients.Add ("someone@example.com") 
      oMail.Recipients.ResolveAll 
      oMail.SendUsingAccount = oAccount 
      oMail.Send 
     End If 
     Next 
    End Sub 

    Saturday, May 2, 2015 9:29 AM
  • You cannot do that using the Outlook Object Model.

    Extended MAPI (C++ or Delphi only): call IMAPISession.SetDefaultStore

    Redemption (any language): set RDOStore.Default property to true.


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


    Saturday, May 2, 2015 5:55 PM

All replies

  • Hello Sridhar,

    The Outlook object model doesn't provide anything for setting the default account in Outlook. These settings are stored in the windows registry. The How do I get Outlook to actually default new emails to a specific account and not ignore the default setting? forum thread states the following:

    Out of the box, Outlook 2010 SP1 and Outlook 2013 use the default account for Send to commands but not for new messages created while viewing a pst file (when a POP account is assigned to the pst file), unless you set a registry value to always force the use of the default account.

    To force all new messages to use the default email account, regardless of which pst file you are viewing, browse to the following registry subkey in Outlook 2010 and add a DWORD named NewItemsUseDefaultSendingAccount:

    HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Options\Mail
    DWORD value: NewItemsUseDefaultSendingAccount
    Value: 1
    

    In Outlook 2013, the key is:

    HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\Options\Mail
    DWORD value: NewItemsUseDefaultSendingAccount
    Value: 1
    

    Registry key to force account selection every time

    This fix is simple, but can get annoying, fast, since it forces the user to select an account every time they send a new message. (Replies and Forwards always use the account the message arrived on.)

    This might be good for people who use multiple accounts and frequently (accidentally) send using the wrong account, especially if they are sending sensitive documents, as it will almost eliminate accidentally sending email from the wrong account.

    HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\14.0\outlook\options
    Value Name: ForceAccountSelection
    Value type: REG_DWORD: 1 for force, 0 to disable.
    

    In Outlook 2013, the registry key is:

    HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\15.0\outlook\options
    Value Name: ForceAccountSelection
    Value type: REG_DWORD: 1 for force, 0 to disable.

    Also see Outlook 2010 does not honor the default sending account .

    You may also find the SendUsingAccount property of the MailItem class which allows to set an Account object that represents the account under which the MailItem is to be sent. For example:

    Sub SendUsingAccount() 
     Dim oAccount As Outlook.account 
     For Each oAccount In Application.Session.Accounts 
     If oAccount.AccountType = olPop3 Then 
      Dim oMail As Outlook.MailItem 
      Set oMail = Application.CreateItem(olMailItem) 
      oMail.Subject = "Sent using POP3 Account" 
      oMail.Recipients.Add ("someone@example.com") 
      oMail.Recipients.ResolveAll 
      oMail.SendUsingAccount = oAccount 
      oMail.Send 
     End If 
     Next 
    End Sub 

    Saturday, May 2, 2015 9:29 AM
  • You cannot do that using the Outlook Object Model.

    Extended MAPI (C++ or Delphi only): call IMAPISession.SetDefaultStore

    Redemption (any language): set RDOStore.Default property to true.


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


    Saturday, May 2, 2015 5:55 PM