共用方式為


檢查經理對會議邀請的回應

此範例說明如何使用 GetExchangeUser () GetExchangeUserManager () 方法來檢查目前用戶經理對會議邀請的回應狀態。

範例

注意事項

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

若要判斷指定的收件者是否已接受或拒絕要求的會議,請使用與 AppointmentItem 對象相關聯之 Recipients 集合中 Recipient 物件的 MeetingResponseStatus 屬性。

在下列程式代碼範例中,CheckManagerResponseStatus 會接受 AppointmentItem 對象作為參數。 CheckManagerResponseStatus 會藉由呼叫目前使用者的 GetExchangeUser 方法來取得 ExchangeUser 物件。 CheckManagerResponseStatus 接著會呼叫 GetExchangeUserManager 方法,以取得與目前使用者的管理員相關聯的 ExchangeUser 物件。 藉由使用 CompareEntryIDs (String, String) 方法的 NameSpace 物件, 範例接著會檢查與 AppointmentItem 物件相關聯的 Recipient 物件是否與代表使用者管理員的 ExchangeUser 物件相同。 如果 CompareEntryIDs 傳回 true,則會在 Recipients 集合中找到使用者的管理員,而 CheckManagerResponseStatus 會傳回管理員的 MeetingResponseStatus。 如果 CompareEntryIDs 傳回 false,CheckManagerResponseStatus 會傳回 Null 參考。

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 Object CheckManagerResponseStatus(Outlook.AppointmentItem appt)
{
    try
    {
        if (appt == null)
        {
            throw new ArgumentNullException();
        }
        Outlook.AddressEntry user =
            Application.Session.CurrentUser.AddressEntry;
        Outlook.ExchangeUser userEx = user.GetExchangeUser();
        if (userEx == null)
        {
            return null;
        }
        Outlook.ExchangeUser manager =
            userEx.GetExchangeUserManager();
        if (manager == null)
        {
            return null;
        }
        foreach (Outlook.Recipient recip in appt.Recipients)
        {
            if (Application.Session.CompareEntryIDs(
                recip.AddressEntry.ID, manager.ID))
            {
                return recip.MeetingResponseStatus;
            }
        }
        return null;
    }
    catch (Exception ex)
    {
        Debug.WriteLine(ex.Message);
        return null;
    }
}

另請參閱