Applescript to copy web page into macmail

Discussion in 'Mac Programming' started by robttycab, Dec 7, 2015.

  1. robttycab macrumors newbie

    Dec 7, 2015

    Sounds weird, but I have a mac word doc that I web preview in Safari and use Safari "share>email this page" to get the entire html content into the email. I have a script already that takes email addresses from excel one at a time and inserts it into the recipients and inserts the subject as well. I just can't figure out the applescript commands to send the active safari page into mac mail. Sorry if this is too complicated.

    Your assistance is greatly respected


    set {firstName, eAddress} to getData()
    repeat with i from 1 to count firstName
    tell application "Mail"
    set mymail to make new outgoing message at the beginning of outgoing messages with properties {subject:"Your Complimentary Chocolate Recipe Book"}
    tell mymail
    makenewto recipientat beginning of to recipientswith properties {address:itemi of eAddress}

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

    end tell

    end repeat

    on getData()
    set colA to {}
    set colB to {}
    tell application "Microsoft Excel"
    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
  2. kryten2 macrumors 6502a

    Mar 17, 2012
    Looking at Safari's dictionary, I can see an email contents command.
    Example :

    tell application "Safari"
    tell window 1
    email contents of tab 1
    end tell
    end tell

Share This Page