共用方式為


取得目前使用者管理員的相關信息

此範例示範如何取得 (資訊,例如名稱、職稱和電話號碼) 目前使用者的經理。

範例

注意事項

下列程式代碼範例是 Microsoft Office Outlook 2007 程式設計應用程式的摘錄。

在下列程式中,GetManagerInfo 會呼叫 GetExchangeUserManager () 方法來取得 ExchangeUser 物件,代表組織階層中 ExchangeUser 的管理員。 此程式會測試登入的使用者是否在在線,以確保 GetExchangeUserManager 可以傳回 ExchangeUser 物件。 如果使用者未上線, GetExchangeUserManager 會傳回 Null 參考。 GetManagerInfo 接著會將管理員資訊寫入接聽程式集合的追蹤接 程式。

If you use Visual Studio to test this code example, you must first add a reference to the Microsoft Outlook 15.0 Object Library component and specify the Outlook variable when you import the Microsoft.Office.Interop.Outlook namespace. The using statement must not occur directly before the functions in the code example but must be added before the public Class declaration. The following line of code shows how to do the import and assignment in C#.

using Outlook = Microsoft.Office.Interop.Outlook;
private void GetManagerInfo()
{
    Outlook.AddressEntry currentUser =
        Application.Session.CurrentUser.AddressEntry;
    if (currentUser.Type == "EX")
    {
        Outlook.ExchangeUser manager =
            currentUser.GetExchangeUser().GetExchangeUserManager();
        if (manager != null)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("Name: "
                + manager.Name);
            sb.AppendLine("STMP address: "
                + manager.PrimarySmtpAddress);
            sb.AppendLine("Title: "
                + manager.JobTitle);
            sb.AppendLine("Department: "
                + manager.Department);
            sb.AppendLine("Location: "
                + manager.OfficeLocation);
            sb.AppendLine("Business phone: "
                + manager.BusinessTelephoneNumber);
            sb.AppendLine("Mobile phone: "
                + manager.MobileTelephoneNumber);
            Debug.WriteLine(sb.ToString());
        }
    }
}

另請參閱