2010-07-12 5 views
1

다른 Outlook 일정표에서 일부 일정을 읽은 다음 큰 화면으로 표시하려고합니다. 내 컴퓨터에서 모든 것이 잘 작동하지만 (Outlook 2010, Win7 x64), 클라이언트의 PC (Outlook2003, Win XP)에서는 프로그램이 모든 약속을 찾지 못합니다. 도구를 디버깅 할 수있는 확인란을 추가하면 8과 12 사이의 약속 (12 개가 있어야 함)과 항상 6이 없습니다. 어떤 문제인지 잘 모릅니다. 그래서 나를 도와주세요. 나는 몇 가지 새로운 정보가Outlook Interop이 다른 결과를 제공합니다.

this.Appointments = new List<AppointmentItem>(); 

foreach (MAPIFolder folder in this.SelectedCalendars) 
{ 
    foreach (object app in folder.Items) 
    { 
     if (app is AppointmentItem && ((AppointmentItem)app).Start.Date == DateTime.Now.Date) 
     { 
      this.Appointments.Add(((AppointmentItem)app)); 
     } 
    } 
} 

this.Appointments.Sort(
    delegate(AppointmentItem App1, AppointmentItem App2) 
    { 
     return App1.Start.CompareTo(App2.Start); 
    }); 

업데이트

:

여기에 코드입니다. 이 예외가 있습니다. 어떤 생각을 어떻게 처리 할까?

The COM-Object of the type "System.__ComObject" couldn't be changed to the Interfacetype "Microsoft.Office.Interop.AppointmentItem. This procedure couldn't be run, because the Queryinterface-Call to the COM-Component for the interface with IID "{00063033-0000-0000-C000-000000000046}" couldn't be run because of the following error: Interface not supported (Exception _HRESULT:0x80004002 (E_NOINTERFACE)).

답변

0

그것은 COM 개체에 대한 실패 반복자 수 있습니다)

는 (나는 독일어에서 영어로 번역, 당신은 이해 바랍니다). 당신이 다시 작성하는 경우

그것은 작동합니까 명시 적으로 GetFirst()GetNext()를 호출하는 루프를 :

object app = folder.Items.GetFirst(); 
while (app != null) 
{ 
    if (app is AppointmentItem && ((AppointmentItem)app).Start.Date == DateTime.Now.Date) 
    { 
     this.Appointments.Add(((AppointmentItem)app)); 
    } 
    app = folder.Items.GetNext(); 
} 

또한 시작 날짜에 Items 컬렉션을 필터링 할 시도 할 수 있습니다.

var items = folder.Items.Restrict("[Start] < '01/31/2009 00:00 AM' and [Start] >= '01/30/2009 00:00 AM"); 
+0

소리가 좋습니다. 나는 그것을 시도 할 것이다! 1-2 일 걸릴 수 ... –

+1

흠,하지만,이 문제를 해결할 수 없습니다. Outlook/Exchange에서 문제가 될 수 있다고 생각하기 시작합니다. –

+0

2003 년과 2010 년에 folder.Items.Count가 같은 번호를 사용합니까? –

0

앞으로 호환되어야하는 Office Interops 2003 버전에 바인딩되어 있는지 확인하십시오.

+0

이미 확인되었습니다. 그냥 즐거움을 위해 v14에서도 시도해 보았고 같은 결과를 얻었습니다 (FYI). –

관련 문제