Jump to content

Recommended Posts

I'm creating my first Alfred workflow. It takes a keyword, and creates a new outgoing message in Mail.app using AppleScript. Something like this...

on alfred_script(q)
    set theSubject to q
    tell application "Mail"
        activate
        set theMessage to make new outgoing message with properties {visible:true}
        tell theMessage
              set subject to theSubject
              set content to theContent
        end tell
    end tell
end alfred_script

This works fine when I explicitly set theContent to be a text string 

set theContent to "this is my content"

However, there is more complexity and conditional statements in my actual script, and to keep things organised I want to set theContent to read from a text file. 

set theContent to paragraphs of (read file "the_content.txt")

This doesn't work!

 

I'm very grateful for some pointers to help me get my first workflow up and running:

 

  1. Where should I place "the_content.txt"? In Alfred.alfredpreferences/workflows/user.workflow.123?
  2. Would I need to define the absolute path to "the_content.txt" in my AppleScript? Or will a relative path suffice?
  3. Am I reading "the_content.txt" correctly?

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...