我使用Apple腳本從Microsoft Outlook中獲取所需的詳細信息,它完全在Mountian Lion OsX(10.8.3)上正常工作,但是當我使用相同的腳本時失敗並拋出錯誤「」預期「,」但發現財產「。「Expected」,「但使用Apple腳本發現屬性錯誤
下面是我正在使用的Apple腳本。
on encodeXML(s)
set AppleScript's text item delimiters to "&"
set components to every text item of s
set AppleScript's text item delimiters to "&"
set s to components as string
set AppleScript's text item delimiters to ""
set AppleScript's text item delimiters to "<"
set components to every text item of s
set AppleScript's text item delimiters to "<"
set s to components as string
set AppleScript's text item delimiters to ">"
set components to every text item of s
set AppleScript's text item delimiters to ">"
set s to components as string
set AppleScript's text item delimiters to "\""
set components to every text item of s
set AppleScript's text item delimiters to """
set s to components as string
set AppleScript's text item delimiters to "'"
set components to every text item of s
set AppleScript's text item delimiters to "'"
set s to components as string
set AppleScript's text item delimiters to ""
return s
end encodeXML
on meetingNumber(s)
set AppleScript's text item delimiters to "Meeting Number:"
set components to every text item of s
if (count of components) is less than 2 then
return ""
end if
set s to second text item of components
set AppleScript's text item delimiters to "To join"
set components to every text item of s
set s to first text item of components
set AppleScript's text item delimiters to "<"
set components to every text item of s
set s to first text item of components
set AppleScript's text item delimiters to "&"
set components to every text item of s
set s to first text item of components
set AppleScript's text item delimiters to "----"
set components to every text item of s
set s to first text item of components
set AppleScript's text item delimiters to " "
set components to every text item of s
set AppleScript's text item delimiters to ""
return components as string
end meetingNumber
on trimContents(s)
set AppleScript's text item delimiters to "Meeting Number:"
set components to every text item of s
if (count of components) is less than 2 then
return ""
end if
set s to second text item of components
set AppleScript's text item delimiters to "To join"
set components to every text item of s
set s to first text item of components
set AppleScript's text item delimiters to "<"
set components to every text item of s
set s to first text item of components
set AppleScript's text item delimiters to "&"
set components to every text item of s
set s to first text item of components
set AppleScript's text item delimiters to "----"
set components to every text item of s
set AppleScript's text item delimiters to ""
return "Meeting Number: " & first text item of components
end trimContents
on getEventKeys(theEvent)
set r to ""
tell application "Microsoft Outlook"
set r to r & " <wxp:meeting>
"
set r to (r & " <wxp:appID>" & id of theEvent as string) & "</wxp:appID>
"
set t to (content of theEvent as string)
set t to my trimContents(t)
set r to (r & " <wxp:content>" & my encodeXML(t)) & "</wxp:content>
"
set r to r & " </wxp:meeting>
"
end tell
return r
end getEventKeys
on getEvent(theEvent)
set retVal to ""
tell application "Microsoft Outlook"
set retVal to retVal & "<wxp:meeting>"
set retVal to (retVal & "<wxp:subject>" & my encodeXML(subject of theEvent as string)) & "</wxp:subject>"
set retVal to (retVal & "<wxp:organizer>" & organizer of theEvent as string) & "</wxp:organizer>"
set retVal to (retVal & "<wxp:startDate>" & start time of theEvent as string) & "</wxp:startDate>"
set retVal to (retVal & "<wxp:endDate>" & end time of theEvent as string) & "</wxp:endDate>"
set retVal to (retVal & "<wxp:appID>" & ID of theEvent as string) & "</wxp:appID> "
set outType to ""
if (is recurring of theEvent) then
set recur to recurrence of theEvent
set recurType to recurrence type of recur as string
if recurType is "daily" then
set outType to "DAILY"
else if recurType is "weekly" then
set outType to "WEEKLY"
else if recurType is "absolute monthly" or recurType is "relative monthly" then
set outType to "MONTHLY"
else if recurType is "absolute yearly" or recurType is "relative yearly" then
set outType to "YEARLY"
end if
set retVal to retVal & "<wxp:repeatType>" & outType & "</wxp:repeatType>
"
set retVal to retVal & "<wxp:interval>" & occurrence interval of recur & "</wxp:interval>
"
if end type of end date of recur as string is "end numbered type" then
set retVal to retVal & "<wxp:afterMeetingNumber>" & data of end date of recur & "</wxp:afterMeetingNumber>
"
else if end type of end date of recur as string is "end date type" then
set retVal to (retVal & "<wxp:expirationDate>" & data of end date of recur as string) & "</wxp:expirationDate>
"
end if
if recurType is "relative monthly" then
set retVal to retVal & "<wxp:weekInMonth>" & ordinal of recur & "</wxp:weekInMonth>"
end if
if recurType is "weekly" or recurType is "relative monthly" then
set bitmap to 0
if sunday of days of week of recur then
set bitmap to bitmap + 1
end if
if monday of days of week of recur then
set bitmap to bitmap + 2
end if
if tuesday of days of week of recur then
set bitmap to bitmap + 4
end if
if wednesday of days of week of recur then
set bitmap to bitmap + 8
end if
if thursday of days of week of recur then
set bitmap to bitmap + 16
end if
if friday of days of week of recur then
set bitmap to bitmap + 32
end if
if saturday of days of week of recur then
set bitmap to bitmap + 64
end if
set retVal to retVal & "<wxp:dayInWeek>" & bitmap & "</wxp:dayInWeek>
"
end if
else
set retVal to retVal & "<wxp:repeatType></wxp:repeatType>
"
end if
if (has reminder of theEvent) then
set retVal to (retVal & " <wxp:reminder>" & reminder time of theEvent as string) & "</wxp:reminder>
"
end if
--set attendees to attendee of theEvent
set retVal to retVal & " <wxp:attendees>
"
repeat with theAttendee in required attendee of theEvent
set retVal to retVal & my writeAttendee(theAttendee, "REQUIRED")
end repeat
repeat with theAttendee in optional attendee of theEvent
set retVal to retVal & my writeAttendee(theAttendee, "OPTIONAL")
end repeat
repeat with theAttendee in resource attendee of theEvent
set retVal to retVal & my writeAttendee(theAttendee, "RESOURCE")
end repeat
set retVal to retVal & " </wxp:attendees>
"
set retVal to (retVal & " <wxp:content>" & my encodeXML(content of theEvent as string)) & "</wxp:content>
"
set retVal to retVal & " </wxp:meeting>
"
end tell
return retVal
end getEvent
on writeAttendee(theAttendee, theType)
tell application "Microsoft Outlook"
set retVal to ""
if (status of theAttendee as string) is not "declined" then
set em to email address of theAttendee
set retVal to retVal & " <wxp:attendee>
"
try
set retVal to (retVal & " <wxp:name>" & my encodeXML(name of em as string)) & "</wxp:name>
"
end try
set retVal to (retVal & " <wxp:ID>" & address of em as string) & "</wxp:ID>
"
set retVal to retVal & " <wxp:type>" & theType & "</wxp:type>
"
set retVal to retVal & " </wxp:attendee>
"
end if
return retVal
end tell
end writeAttendee
可以請看看它,讓我知道我在做什麼這裏錯了。
在此先感謝。
Ravi Kishore。
請說明它不工作的操作系統(即不是10.8.3)也可以演示如何調用它,因爲這只是一組函數。 – adamh
IT僅在10.9.x或更高版本上運行。我在outlook上調用上面的蘋果腳本來捕獲會議詳細信息。 –
爲什麼用「objective-c」和「cocoa」標記Q? –