在 safari 中使用 applescript 在邮件中发送内容

Use applescript with safari to send content in mail

听起来很奇怪,但我有一个 mac word 文档,我在 Safari 中进行网络预览并使用 Safari "share>email this page" 将整个 html 内容放入电子邮件中。我已经有一个脚本,它一次从 excel 中获取一个电子邮件地址,并将其插入收件人并插入主题。我只是想不出将活动的 safari 页面发送到 mac 邮件的 applescript 命令。对不起,如果这太复杂了。

非常感谢您的协助

干杯 抢

set {firstName, eAddress} to getData()

repeat with i from 1 to count firstName
tell application "Mail"
    activate
    set mymail to make new outgoing message at the beginning of outgoing messages with properties {subject:"Your Complimentary Chocolate Recipe Book"}
    tell mymail
        make new to recipient at beginning of to recipients with properties {address:item i of eAddress}


    end tell
    --show message window (otherwise it's hidden)
    set visible of mymail to true
    --bring Mail to front
    activate
    send mymail
    set m to random number from 45 to 300
    delay m
end tell
end repeat


on getData()
set colA to {}
set colB to {}
tell application "Microsoft Excel"
    activate
    tell active sheet
        set lastRow to first row index of (get end (last cell of column 1) direction toward the top)

        repeat with i from 3 to lastRow
            set end of colA to (value of range ("A" & i))
            set end of colB to (value of range ("B" & i))
        end repeat
    end tell
end tell

return {colA, colB}
end getData

抢,

如果你想获取 HTML 来源:

on get_page_data()
  tell application "Safari"
    return source of document of windows whose visible is true
  end tell
end

然后您可以在代码中的 make new 行设置外发消息的内容 属性:

tell application "Mail"
    set mymail to make new outgoing message at the beginning of outgoing messages with properties {subject:"Your Complimentary Chocolate Recipe Book", content: get_page_data()}
-- etc
end tell