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

时间:2015-12-08 03:52:02

标签: html excel email safari applescript

听起来很奇怪,但我有一个mac word doc,我在Safari中进行网页预览并使用Safari"分享>通过电子邮件发送此页面"将整个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

1 个答案:

答案 0 :(得分:0)

罗布,

如果您想获取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