I receive an email notice from my Credit Card processor of the day’s transactions. I’m trying to script that into an iCal event 3 days later so I can easily see what’s coming in. Works OK on Mon and Tues, but I’m trying to get iCal to count days: if the mail comes on Wed, Thurs or Fri, set the event day to Mon, Tues, or Wed, not Sat/Sun.
I’m also trying to change the TIME of the new event to 09:00:00 without success.
Any insight from you brainiacs is much appreciated.
I’ve managed to work myself into this hole right here by patching together snippets from here and there:
tell application "Mail"
set the_messages to selection
repeat with i from 1 to count of the_messages
set the_message to (a reference to item i of the_messages)
set the_content to (content of the_message)
set the_date_sent to (date sent of the_message)
set DepositDate to the_date_sent - 12 * hours + 3 * days
-- the day the mail is sent sometimes comes after midnight, so the above calculation insures that the day in question is actually the day of the deposit.
tell application "iCal"
set FollowUpEvent to (make new event at end of every event of calendar 3)
tell FollowUpEvent
if DepositDate contains "Saturday" then
set NewDepositDate to DepositDate + 2 * days
if DepositDate contains "Sunday" then
set NewDepositDate to DepositDate + 2 * days
end if
else
set NewDepositDate to DepositDate
end if
--set time of NewDepositDate to "09:00:00 AM"
set start date to NewDepositDate
set end date to NewDepositDate + 5 * minutes
set summary to "Today's Deposit"
set description to the_content
end tell
end tell
end repeat
end tell
Bonus Question: I’m also trying to pull the relevant data from the guts of the message, but can’t figure out how to script this part. Here’s the relevant data from the email that’s sent, less anything identifying. The mail comes in as plain text with the lines broken as shown. I only want the “Net Batch Total” line, or better yet, just the total, to use as the title of the iCal entry.
[code] not really code:
Your Authorize.Net ID is: 000000000
Dear “User”,
The following is your Credit Card settlement report for Thursday, October
20, 2005.
Transaction Volume Statistics for Settlement Batch dated 20-Oct-2005
22:31:40:
Net Batch Total: 462.43
Number of Charge Transactions: 4
Amount of Charge Transactions: 462.43
Number of Refund Transactions: 0
Amount of Refund Transactions: 0.00
And then there’s more junk below…[/code]
Model: PB G4 667
AppleScript: 1.9.3
Browser: Safari 125.12
Operating System: Mac OS X (10.3.9)