anonymoose
anonymoose

Reputation: 1243

How to add the current month in AppleScript?

I have a script that I'm using to automate a small workflow but I am stuck trying to get the Subject to list the current month.

Here is my script:

tell application "Finder" to set selectedItem to item 1 of (get selection)
set theAttachment to selectedItem as alias
set fileName to name of selectedItem

tell application "Microsoft Outlook"
    set newMessage to make new outgoing message with properties {subject:"(current month) as string Message from John Doe"}
    tell newMessage
        make new attachment with properties {file:theAttachment}
    end tell
    open newMessage
    get newMessage
end tell

Is this possible? I've tried searching online and in Script Debugger but I keep coming up short. Thanks in advance.

Upvotes: 0

Views: 200

Answers (1)

CJK
CJK

Reputation: 6102

I don't use Microsoft Outlook, so I'm going to assume that your script executes without error, but simply produces an undesired result, namely an new outgoing email with the words "(current month) as string Message from John Doe" in the subject line.

On this basis, to get your subject line to contain only the current month, find the relevant line in your script that contains this:

{subject:"(current month) as string Message from John Doe"}

and replace it with this

{subject:(current date)'s month as text}

If you want the subject line to include additional text after the month, as your original script does, then you can instead replace it with this:

{subject:((current date)'s month as text) & " Message from John Doe"}

Upvotes: 1

Related Questions