获取所选邮箱的电子邮件地址

Get e-mail address of selected mailboxes

我正在尝试接收在邮件中处于活动状态的帐户的邮件地址。

到目前为止我做了以下事情

tell application "Mail"
    set selected to selected mailboxes of message viewer 1
end tell

tell application "Mail"
    email addresses of every account
end tell

但不知何故我做不到

tell application "Mail"
    set selectedMailboxes to selection
    set theAccount to account of selection
    return theAccount
end tell

最后一个 applescript 不起作用。如何找回message vieview 1邮箱的账号?

试试这个

tell application "Mail"
    try
        set selectedMailbox to item 1 of (get selected mailboxes of message viewer 1)
        set mailAddresses to email addresses of account of selectedMailbox
    on error
        display dialog "No Mailbox selected"
    end try
end tell

由于一个帐户可以有多个邮件地址,即使只有一个地址,变量mailAddresses的class也是一个列表。

通过索引号(从 1 开始)获取您想要的地址

set myAddress to item 1 of mailAddresses

set myAddress to second item of mailAddresses