AndrewJudd

Applescript for default email

Discussion created by AndrewJudd on Mar 26, 2016
Latest reply on Mar 29, 2016 by user19752

Hi all,

 

I have the below applescript (bottom of post) which works fine with Mac Mail. I was wondering how to make the script choose the default email program a user might be using. Hunting around online I found this -

 

on run
  set mailClient to getDefaultMailClient() -- store application id
  tell application id mailClient to activate -- tell mail client to do something
end run

 

but I'm not sure how to piece it all together?

 

Anyone have any ideas?

 

Thanks!

 

 

 

 

-- tell application "FileMaker Pro Advanced"

set theMessage to cell "Message" of current record

set theAttachments to cell "Attachments" of current record

    -- return-separated Mac:file paths

-- end tell

 

set attachmentList to {}

repeat with i in paragraphs of theAttachments

    set theAttachment to i

    set aliasAttachment to theAttachment as alias

    set attachmentList to attachmentList & aliasAttachment

end repeat

 

set theMessage to theMessage & return & return

-- otherwise it jams it up against the text

 

tell application "Mail"

activate

    set newMessage to make new outgoing message with properties {content:theMessage}

    tell newMessage

tell content

            repeat with i in attachmentList

                make new attachment with properties {file name:i} at after the last paragraph

            end repeat

        end tell

 

        save newMessage

        -- send newMessage

        -- switch the commenting on the above 2 lines to send immediately

    end tell

end tell

Outcomes