configuring the proper date strings in AppleScript...

Hello everyone,

I have an interesting question…I’m trying to create a script that send an e-mail to a specific address on a weekly basis. The e-mail is being sent to a laundry pickup service, which needs at least 2 days notice before pickup. So, if I run the script let’s say every Saturday, I need it to automatically figure out the date that is 2 days after the date when it runs, and insert that into the e-mail output. Look at the script below:


set theOutput to "Hello,

I'd like laundry pickup at 160 Massachusetts Avenue, Boston MA. If you have any questions, feel free to contact me on my cell, (609)922-3838.
Please have the driver call me so I can meet him outside the building.

Thanks so much,

Rocco Fiorentino"

tell application "Mail"
	activate
	set theMessage to make new outgoing message with properties {visible:true, sender:"rfiorentino1@berklee.edu", subject:"laundry pickup", content:theOutput}
	tell theMessage
		make new to recipient with properties {address:"delivery@sarnidrycleaners.com"}
		send
	end tell
end tell



I’d like this to read instead:
"I’d like laundry pickup at address ---- on date {3 days after the current date}.

Is this possible through a script, or am I better off doing this manually. Also, I was planning to run this as an application and have calendar run the application as an alert for the weekly event. However, if my laptop isn’t on at that time, I assume the e-mail won’t be sent…is there any way around this, or a better way of scheduling the script?

Thanks so much in advance for any help.

Rocco

Hi.

The function ‘current date’ returns the system date and time at the moment it’s executed.

The constant ‘days’ is equal to the number of seconds in a day.

So 48 hours after the script runs is:

(current date) + 2 * days

You won’t want the result’s time component in your message, so what you need to concatenate into ‘theOutput’ is:

date string of ((current date) + 2 * days)

Something like this?


set _today to current date
set day of _today to ((day of _today) + 3)
return _today

so I now have the following in the output, but instead of outputting the date, it outputs what’s actually in the quotes (e.g. the script itself)


set theOutput to "Hello,

I'd like laundry pickup at 160 Massachusetts Avenue, Boston MA on 'date string of ((current date) + 2 * days)'. If you have any questions, feel free to contact me on my cell, (609)922-3838.
Please have the driver call me so I can meet him outside the building.

Thanks so much,

Rocco Fiorentino"


What am I doing wrong here? Also, is there a way to illuminate the year from being written in the output of the date? thanks so much!

try something like this rfscripter

set the_date to date string of ((current date) + 2 * days)
set theOutput to "Hello,

I'd like laundry pickup at 160 Massachusetts Avenue, Boston MA on " & the_date & " If you have any questions, feel free to contact me on my cell, (609)922-3838.
Please have the driver call me so I can meet him outside the building.

Thanks so much,

Rocco Fiorentino"