Доступ к вложенным свойствам с помощью AppleScript - PullRequest
1 голос
/ 25 марта 2020

У меня есть appleScript, который я использую для извлечения нескольких фрагментов информации из календарного события Outlook, включая дату начала, заголовок и участников. У меня проблема с классом участников. Я просто пытаюсь получить свойство "name" класса, но я получаю следующую ошибку. Из того, что я вижу, свойство «имя» существует как часть свойства «адрес электронной почты» класса «участники», поэтому оно вложено довольно глубоко. Я хотел бы создать список только имен участников.

Вот ошибка

Can’t get item 1 of {name:"Attendee Name", address:"attendee@address.com", type:unresolved address}.

Вот скрипт. Сначала вы должны выбрать событие календаря в Outlook

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

global calendarTitle
global calendarDate
global calendarStart
global calendarAttendees
set show_note_in_new_window to true
tell application "Microsoft Outlook"
    activate
    delay 0.2
    set calendarEvent to selection
    -- if there are no tasks selected, warn the user and then quit
    if calendarEvent is {} then
        display dialog "Please select a calendar event first and then run this script." with icon 1
        return
    end if
    set calendarTitle to subject of calendarEvent
    set calDate to {month, day, year} of (current date)
    set calendarDate to calDate as text
    set calStart to start time of calendarEvent
    set calendarStart to calStart as text
    set calendarAttendees to get attendees of calendarEvent
    repeat with attendeeEmail in calendarAttendees
        set attendeeEmails to get email address of attendeeEmail
    end repeat
    repeat with attendeeName in attendeeEmails
        set attendeeEmailName to get name of attendeeName
    end repeat
    tell application "System Events"
        repeat with attendee in attendeeEmailName
            display dialog attendee
        end repeat
    end tell
end tell

Ответы [ 2 ]

1 голос
/ 25 марта 2020

Исходя из комментариев выше, я думаю, что вы хотите сделать это примерно так:

set calendarAttendees to get attendees of calendarEvent
set attendeeEmails to get email address of every calendarAttendees
set attendeeEmailNames to {}
repeat with thisEmail in attendeeEmails
    copy name of thisEmail to end of attendeeEmailNames
end repeat

строка 2 собирает адреса электронной почты каждого участника в список attendeeEmails, затем строка 3 через 6 извлекает имена из каждой записи и сохраняет их в attendeeEmailNames. Возможно, вы сможете сделать все это в одну строку (в строке 2) следующим образом:

set attendeeEmailNames to name of every email address of calendarAttendees

Но у меня нет Outlook, чтобы проверить это, поэтому я не могу точно сказать, что это работа.

0 голосов
/ 26 марта 2020

Разобрался.

set emailList to get every email address of every attendee of calendarEvent

set nameList to {}
repeat with theName in emailList
    copy name of theName to end of nameList
end repeat
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...