Я нашел какой-нибудь работоспособный код, чтобы найти и распечатать, чтобы записать все даты начала и темы назначения для заданного диапазона дат. Это хорошо работает.Календарь Outlook VBA, чтобы найти все встречи с определенной строкой в них
Что мне нужно - это способ вывода следующих данных: Дата начала/время; Предмет; «Текст строки из органа назначения», строка X
Но только для тех встреч в диапазоне данных, которые также имеют определенную строку в Органе назначения.
Это часть кода я использую ... Dim oAppt Как Outlook.AppointmentItem MyFile.WriteLine (oAppt.Start & "" & oAppt.Subject)
я не нашел любые методы или функции для использования на oAppt.Body, с помощью которых можно выполнить поиск. Ниже приведен полный код моего сценария VBA, как он стоит прямо сейчас:
Sub FindAppts()
Dim daStart, daEnd As Date
Dim oCalendar As Outlook.Folder
Dim oItems As Outlook.Items
Dim oItemsInDateRange As Outlook.Items
Dim oFinalItems As Outlook.Items
Dim oAppt As Outlook.AppointmentItem
Dim strRestriction As String
' Declare a FileSystemObject, and prepare it to take the data.
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile("c:\test\CalendarLogOutput.log", True)
daStart = Format(Date, "mm/dd/yyyy hh:mm AMPM")
daEnd = DateAdd("d", 30, daStart)
daEnd = Format(daEnd, "mm/dd/yyyy hh:mm AMPM")
Debug.Print "Start:", daStart
Debug.Print "End:", daEnd
' Construct a filter for the next 30-day date range.
strRestriction = "[Start] >= '" & daStart _
& "' AND [End] <= '" & daEnd & "'"
Debug.Print strRestriction
Set oCalendar = Application.Session.GetDefaultFolder(olFolderCalendar)
Set oItems = oCalendar.Items
' To include recurring appointments, sort by using the Start property.
oItems.IncludeRecurrences = True
oItems.Sort "[Start]"
' Restrict the Items collection for the 30-day date range.
Set oItemsInDateRange = oItems.Restrict(strRestriction)
' Construct a filter for subjects that contain ”team”.
Const PropTag As String = "http://schemas.microsoft.com/mapi/proptag/"
strRestriction = "@SQL=" & Chr(34) & PropTag _
& "0x0037001E" & Chr(34) & " like '%team%'"
' Restrict the last set of filtered items for the subject.
Set oFinalItems = oItemsInDateRange.Restrict(strRestriction)
' Sort and print the final results.
oFinalItems.Sort "[Start]"
For Each oAppt In oFinalItems
'Here I need to find out how large the body is...
If oAppt.Body.Find("BCFLUP") Is Not Nothing Then
MyFile.WriteLine (oAppt.Start & "; " & oAppt.Subject & "; " & "Requires FLUP")
End If
'This line outputs simple data.
'Debug.Print oAppt.Start, oAppt.Subject
'MyFile.WriteLine (oAppt.Start & ";" & oAppt.Subject)
Next
' Close the file.
MyFile.Close
End Sub