質問

利用は可能で自動化のためのOutlook2003Silverlight4?もあって、いろいろな方法で使用展望2003年から圧倒にSilverlightのですが。

私が使っているSilverlight4とのようにしているとの見通しこのように:

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

のための展望2007/2010すべての作品。

がろうとした際に、利用分野の動的インスタンス(たとえば。セッション)からの展望2003していくNotSupportedException.この見通し2003年の問題です。

この記事 http://msdn.microsoft.com/en-us/library/aa159619%28office.11%29.aspx が無駄に開発できるプラットフォーム用不可能を参考に事務所の組立、COM直).

Type.GetTypeFromProgID 無駄なもSilverlightに対応しておりません。

役に立ちましたか?

解決

最近ようやく見つかり、次のように答えた。の行動に使用できるようになりますので標準見通し2003年のオブジェクトモデルです。すべてのこれらの行動に記載の このMicrosoft第.主な違いは例第びSilverlightコードできませんを参照Interop済組み立てていますし、使用ます。なにかくすべての連絡先からの問い合わせ先一覧またはすべての受信トレイにメールを参照します.最も難しい部分を取得のリスト作成したユーザます。Outlook2003年のオブジェクトモデルの提供の可能性を得るつのみ(デフォルト)アカウント:

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

いますが、残念ながらないに適しました。でも悲しいものですが、ありません。ウィOutlook2003年のオブジェクトモデルです。いただ一つの難しい方の一覧を取得する。

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; }
}

メトリックが利用AutomationFactory.CreateObject("WScript.シェル").このアカウント情報から直接レジストリを使用RegRead方法です。ようにこのコードでものための展望2007/2010.として私にとっての最も好ましい方法の場合口座取得すべき黙々と(する必要がない打上げ見通し前のデータ収集).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top