簡體   English   中英

Outlook加載項讀取服務器設置

[英]Outlook Add-in read Server Settings

我正在尋找一種使用c#編碼的Outlook加載項從Outlook讀出IMAP / Microsoft Exchange設置的方法。

謝謝你幫我

我認為您正在尋找的是Office.Interop.Outlook dll的Accounts接口。

您沒有提到您使用的是哪個版本的Outlook,此代碼適用於由Microsoft MVP Helmut Obertanner編寫的Outlook 2010,摘自此處

using System;
using System.Text;
using Outlook = Microsoft.Office.Interop.Outlook;

namespace OutlookAddIn1
{
    class Sample
    {
        public static void DisplayAccountInformation(Outlook.Application application)
        {

            // The Namespace Object (Session) has a collection of accounts.
            Outlook.Accounts accounts = application.Session.Accounts;

            // Concatenate a message with information about all accounts.
            StringBuilder builder = new StringBuilder();

            // Loop over all accounts and print detail account information.
            // All properties of the Account object are read-only.
            foreach (Outlook.Account account in accounts)
            {

                // The DisplayName property represents the friendly name of the account.
                builder.AppendFormat("DisplayName: {0}\n", account.DisplayName);

                // The UserName property provides an account-based context to determine identity.
                builder.AppendFormat("UserName: {0}\n", account.UserName);

                // The SmtpAddress property provides the SMTP address for the account.
                builder.AppendFormat("SmtpAddress: {0}\n", account.SmtpAddress);

                // The AccountType property indicates the type of the account.
                builder.Append("AccountType: ");
                switch (account.AccountType)
                {

                    case Outlook.OlAccountType.olExchange:
                        builder.AppendLine("Exchange");
                        break;

                    case Outlook.OlAccountType.olHttp:
                        builder.AppendLine("Http");
                        break;

                    case Outlook.OlAccountType.olImap:
                        builder.AppendLine("Imap");
                        break;

                    case Outlook.OlAccountType.olOtherAccount:
                        builder.AppendLine("Other");
                        break;

                    case Outlook.OlAccountType.olPop3:
                        builder.AppendLine("Pop3");
                        break;
                }

                builder.AppendLine();
            }

            // Display the account information.
            System.Windows.Forms.MessageBox.Show(builder.ToString());
        }
    }
}

從文檔中可以看出,從理論上講,這也應該適用於Outlook 2007。

如果打算使用Outlook 2003,則必須做些不同的事情,因為Outlook 2003對象模型不包括對Accounts屬性的訪問。

為此,您要么必須使用第三方庫(例如,兌換),否則請參見此答案

您顯然也可以根據另一個問題的答案使用注冊表。

對於交換設置,您可以檢查此http://msdn.microsoft.com/en-US/exchange

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM