This is a script for iCal, however, when sent to a Windows Outlook user the attachment doesn’t reach them unless it is zipped or placed into a folder. I simply want to know how to place the attachment created in this script into a folder or zip it before it is sent. Whichever is an easier addition to the applescript in this script. Thanks in advance.
-- Mail.applescript
-- iCal
on show_mail_sbrs(subjectLine, messageText, myrecipients)
tell application "Mail"
set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:subjectLine, content:messageText})
repeat with i from (count of myrecipients) to 1 by -1
tell mymail to make new to recipient at beginning of to recipients with properties {name:(item i of myrecipients)}
end repeat
set visible of mymail to true
activate
end tell
end show_mail_sbrs
on show_mail_sbr(subjectLine, messageText, myrecipient)
tell application "Mail"
set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:subjectLine, content:messageText})
tell mymail to make new to recipient at beginning of to recipients with properties {name:myrecipient}
set visible of mymail to true
activate
end tell
end show_mail_sbr
on send_mail_sb(subjectLine, messageText)
tell application "Mail"
set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:subjectLine, content:messageText})
set visible of mymail to true
activate
end tell
end send_mail_sb
on send_mail_sbr(subjectLine, messageText, myrecipient)
tell application "Mail"
set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:subjectLine, content:messageText})
tell mymail to make new to recipient at beginning of to recipients with properties {name:myrecipient}
send mymail
end tell
end send_mail_sbr
on send_mail_sbrp(subjectLine, messageText, myrecipient, invitationPath)
set pfile to POSIX file invitationPath
set myfile to pfile as alias
try
-- define a carriage return
set cr to (ASCII character 13) & (ASCII character 10)
-- retrieve the user's name and e-mail
set listOfAccounts to {}
tell application "Mail"
repeat with oneAccount in every account
set listOfAccounts to listOfAccounts & ¬
{""" & (get full name in oneAccount) & "" <" & ¬
(get email addresses in oneAccount) & ">"}
end repeat
end tell
if ((get length of listOfAccounts) is 1) then
set theAccountTouse to get first item of listOfAccounts
else
set theAccountTouse to ¬
choose from list listOfAccounts ¬
default items (get first item of listOfAccounts) ¬
with prompt ¬
¬
"Please select which mail account to send the invitation from:" without multiple selections allowed and empty selection allowed
end if
-- open and read the ical event file to insert into an e-mail
set myEventFileHandle to ¬
open for access myfile without write permission
set myEventFileContent to read myEventFileHandle
close myEventFileHandle
-- remove the timezone info from the calendar event
-- to make compatable with outlook
set toss to false
set newEventFileContent to ""
set last_line to false
repeat with theLine in paragraphs of myEventFileContent
if theLine contains "BEGIN:VTIMEZONE" then
set toss to true
else if theLine contains "END:VTIMEZONE" then
set last_line to true
set toss to false
end if
if toss is false then
if last_line is true then
set last_line to false
else
set newEventFileContent to newEventFileContent & theLine & cr
end if
end if
end repeat
set myEventFileContent to newEventFileContent
-- pre-pend mail headers to the event contents
set myNewEmailText to ¬
"From: " & theAccountTouse & cr & ¬
"To: " & myrecipient & cr & ¬
"Subject: " & subjectLine & cr & ¬
"MIME-Version: 1.0" & cr & ¬
"Content-Type: text/calendar; method=REQUEST;" & cr & ¬
" charset="utf-8"" & cr & ¬
"Content-Transfer-Encoding: 8bit" & cr & ¬
"Importance: Normal" & cr & cr & ¬
myEventFileContent
-- " name="meeting.ics"" & cr & ¬
-- create a random event file name
set tempMailName to (random number from 1 to 1000000) & ".ics"
set aliasTempMail to "/tmp/" & tempMailName
-- write the new e-mail to a temp file
set myEventFileHandle to ¬
open for access (POSIX file aliasTempMail as string) with write permission
write myNewEmailText starting at 1 to myEventFileHandle
close myEventFileHandle
-- use SENDMAIL to send the file with proper headers
do shell script "sendmail < " & aliasTempMail
-- delete the temp file
do shell script "rm " & aliasTempMail
on error errMsg
display dialog errMsg
end try
end send_mail_sbrp
on send_mail_sbp(subjectLine, messageText, invitationPath)
set pfile to POSIX file invitationPath
set myfile to pfile as alias
tell application "Mail"
set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:subjectLine, content:messageText})
tell mymail
tell content
make new attachment with properties {file name:myfile} at after the last word of the the last paragraph
end tell
end tell
set visible of mymail to true
activate
end tell
end send_mail_sbp