2011-07-19 6 views
2

私はIndependentsoft.Pstを使用してpstファイルからアポイントを抽出しますが、forループは非常に大きなファイルで時間がかかっています。もし誰かがループを持たない方法や、Independentsoft.Pst itemCollectionを配列に変換する方法を私に示す方法があれば、とてもうれしいです。ループなしでpstファイルからアポイントを抽出する

私のコード:

Public Function getAppointment(ByVal file As String) As List(Of String) 
    Dim AppointmentDetails As New List(Of String) 
    Dim App As New List(Of ItemCollection) 
    Dim calendar As Folder 
    Dim PSTfile = New PstFile(file) 
    Dim delta As TimeSpan = MonthCalendar1.SelectionEnd - MonthCalendar1.SelectionStart 
    Dim DelResult As Integer = delta.Duration.Days 

    Using PSTfile 
     calendar = PSTfile.MailboxRoot.GetFolder("calendar") 
     If calendar IsNot Nothing Then 
      Dim items As ItemCollection = calendar.GetItems() 


      For m As Integer = 0 To items.Count - 1 
       If TypeOf items(m) Is Appointment Then 
        Dim appointment As Appointment = DirectCast(items(m), Appointment) 

        AppointmentDetails.Add(appointment.Subject) 
        AppointmentDetails.Add(appointment.CreationTime) 
        AppointmentDetails.Add(appointment.CreationTime.Date) 
        AppointmentDetails.Add(appointment.Duration) 
       End If 
      Next 
     End If 
    End Using 
    Return AppointmentDetails 
End Function 

答えて

0

あなたは、そのプロパティの1のいくつかの特定の値に基づいて予定を見つけることを意味します。 PIAを使用したコードです。

Private Shared Function GetAppointmentsFolder() As Outlook.MAPIFolder 

    Dim result As Outlook.MAPIFolder = Nothing 

    If OutlookApp.ActiveExplorer.CurrentFolder.DefaultItemType = Outlook.OlItemType.olAppointmentItem Then 
     result = OutlookApp.ActiveExplorer.CurrentFolder 
    End If 

    If result Is Nothing Then 
     result = OutlookApp.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar) 
    End If 
    Return result 

End Function 

Public Function GetAppointment(billingInfo as string) As Outlook.AppointmentItem 

Dim appointmentsFolder As Outlook.MAPIFolder = GetAppointmentsFolder() 
    'Try to find an existing appointment (Using Find() Locates and returns an Outlook item object that satisfies the given Filter..) 
    Dim outlookAppointmentItem As Outlook.AppointmentItem = CType(appointmentsFolder.Items.Find("BillingInformation]=""" & pstrAppointmentId & """"), Outlook.AppointmentItem) 

    Return outlookAppointmentItem 

End Function 
+0

いいえ、それは私が意味するものではありません。私は私の任命をしたいが、 "MSオフィス"を設置しないでください。私はローカル、またはイーサネットのような場所にあるpstのOutlookファイルを使ってやりたい – Dudipoli

関連する問題