Applescript to copy web page into macmail

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

  1. robttycab macrumors newbie

    Joined:
    Dec 7, 2015
    #1
    Greetings,

    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

    Cheers
    Rob

    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
    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
    activate
    sendmymail
    set m to random number from 45 to 300
    delaym

    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
     
  2. kryten2 macrumors 6502a

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

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

Share This Page