Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 915193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:50:46+00:00 2026-05-15T17:50:46+00:00

Is it possible to use Automation for Outlook 2003 with Silverlight 4? Or maybe

  • 0

Is it possible to use Automation for Outlook 2003 with Silverlight 4? Or maybe there are some different way to use Outlook 2003 MAPI in Silverlight application?

I’m using Silverlight 4 and I’m trying interact with Outlook in this way:

dynamic outlook = AutomationFactory.GetObject("Outlook.Application"); 

For Outlook 2007/2010 all works fine.

But when I try use any field of dynamic instance (for example outlook.Session) from Outlook 2003 then I’ve get NotSupportedException. It’s only Outlook 2003 problem.

I found article http://msdn.microsoft.com/en-us/library/aa159619%28office.11%29.aspx but it’s useless for Silverlight application (impossible to get reference to office assembly or COM directly).

Type.GetTypeFromProgID is useless too, Silverlight doesn’t support it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:50:47+00:00Added an answer on May 15, 2026 at 5:50 pm

    I’ve finally found an answer.
    Most of actions can be performed using standard Outlook 2003 object model. All these actions described in this Microsoft article.
    Main difference between examples in article and Silverlight code – we can’t refer Interop Outlook assembly, so we need to use dynamics.
    So it’s pretty easy to get all contacts from contact list or all inbox emails (see article). Most difficult part is obtaining list of created user’s accounts. Outlook 2003 object model provide possibility to obtain only one (default) account:

    dynamic outlook = AutomationFactory.CreateObject("Outlook.Application");
    var ns = outlook.GetNamespace("MAPI");
    var defaultAccount = ns.CurrentUser;
    

    But it’s still doesn’t suitable for me. It’s very sad, but there is no Session.Accounts property in Outlook 2003 object model. So I’ve found only one tricky way to obtain list of accounts.

    public class Ol11ImportStrategy 
        {
            const string registryPath = @"HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook\9375CFF0413111d3B88A00104B2A6676\{0}\{1}";
            const string constAccountName = "Account Name";
            const string constEmail = "Email";
            const string constSMTPServer = "SMTP Server";
            const string constName = "Display Name";
            const string constIMAPServer = "IMAP Server";
            const string constPOP3Server = "POP3 Server";
            const string constValueClsid = "clsid";
            const string constContentsAccountClsid_POP3 = "{ED475411-B0D6-11D2-8C3B-00104B2A6676}";
            const string constContentsAccountClsid_IMAP = "{ED475412-B0D6-11D2-8C3B-00104B2A6676}";
    
            public IEnumerable<AccountEntity> GetAccountsInFriendlyFormat()
            {
                List<AccountEntity> accounts = new List<AccountEntity>();
    
                using (dynamic WShell = AutomationFactory.CreateObject("WScript.Shell"))
                {
                    for (int i = 1; i < 1000; i++)
                    {
                        try
                        {
                            string classId = WShell.RegRead(String.Format(registryPath, i.ToString().PadLeft(8, '0'), constValueClsid));
    
                            if (StringComparer.InvariantCultureIgnoreCase.Compare(classId, constContentsAccountClsid_POP3) == 0)
                            {
                                accounts.Add(new AccountEntity
                                {
                                    FriendlyName = GetRegisterElementValue(WShell, i.ToString(), constAccountName),
                                    IncomingMailServer = GetRegisterElementValue(WShell, i.ToString(), constPOP3Server),
                                    Email = GetRegisterElementValue(WShell, i.ToString(), constEmail),
                                    UserName = GetRegisterElementValue(WShell, i.ToString(), constName)
                                });
                                continue;
                            }
    
                            if (StringComparer.InvariantCultureIgnoreCase.Compare(classId, constContentsAccountClsid_IMAP) == 0)
                            {
                                accounts.Add(new AccountEntity
                                {
                                    FriendlyName = GetRegisterElementValue(WShell, i.ToString(), constAccountName),
                                    IncomingMailServer = GetRegisterElementValue(WShell, i.ToString(), constIMAPServer),
                                    Email = GetRegisterElementValue(WShell, i.ToString(), constEmail),
                                    UserName = GetRegisterElementValue(WShell, i.ToString(), constName)
                                });
                                continue;
                            }
    
                            //it isn't POP3 either IMAP
                        }
                        catch (FileNotFoundException e)
                        {
                            //classId isn't found - we can break iterations because we already iterate through all elements
                            break;
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show("Unknown exception");
                        }
                    }
                }
    
                return accounts;
            }
    
            private string GetRegisterElementValue(object scriptShell, string elementNumber, string elementName)
            {
                dynamic shell = scriptShell;
                string currentElement = elementNumber.PadLeft(8, '0');
    
                object[] currentElementData = shell.RegRead(String.Format(registryPath, currentElement, elementName));
    
                byte[] dataBytes = currentElementData.Cast<byte>().ToArray();
                return Encoding.Unicode.GetString(dataBytes, 0, dataBytes.Count()).Trim('\0');
            }
        }
    
    public class AccountEntity
    {
        public string FriendlyName { get; set; }
        public string UserName { get; set; }
        public string Email { get; set; }
        public string AccountType { get; set; }
        public string IncomingMailServer { get; set; }
    }
    

    Main trick is in use of AutomationFactory.CreateObject(“WScript.Shell”). Now it’s possible to get account information directly from registry using RegRead method. By the way this code works well even for Outlook 2007/2010. And as for me it’s most preferable way if accounts should be collected silently (there is no need to launch Outlook before data collecting).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While it is possible to generate PowerPoint presentations automatically using Office Automation , this
I have recently started looking into Google Charts API for possible use within the
Possible Duplicate: Use SVN Revision to label build in CCNET I'm working through the
Is it possible to use a flash document embedded in HTML as a link?
Is it possible to use Apache Subversion (SVN) as general purpose backup tool? (As
Is it possible to use Microsoft Entity Framework with Oracle database?
Is it possible to use an UnhandledException Handler in a Windows Service? Normally I
Is it possible to use gcov for coverage testing of multi-threaded applications? I've set
Is it possible to use an IF clause within a WHERE clause in MS
Is it possible to use both JScript and VBScript in the same HTA? Can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.