Hello,
This is my first post, and pretty much my first AppleScript, so please bear with me…
I have read as much as I could, RTFM&STFW, and I have ordered all the books on AppleScript within a 50 miles radius.
Nevertheless, I have tried all I knew and now I am close to grinding my face with a cheese grater, so please … any help would be greatly appreciated.
I am trying to collect info from System Profiler and attach the file generated to an email, everything goes well until "Mail got an error: Can’t get file “~:Desktop:SYS_Report.txt”
Obviously, the error is there, but I can’t figure it out. newbie brainfart I suppose.
Thanks in advance
property wwwaddress : "http://www.apple.com"
set question to display dialog "Yada yada" with icon 0 buttons {"email", "Apple.com", "Cancel"} default button 2
set answer to button returned of question
if answer is equal to "Apple.com" then
open location wwwaddress
end if
if answer is equal to "email" then
do shell script "system_profiler SPSoftwareDataType > ~/Desktop/SoftReport.txt"
do shell script "system_profiler SPHardwareDataType > ~/Desktop/HardReport.txt"
do shell script " cat ~/Desktop/SoftReport.txt ~/Desktop/HardReport.txt > ~/Desktop/SYS_Report.txt"
do shell script "rm ~/Desktop/SoftReport.txt | rm ~/Desktop/HardReport.txt"
tell application "Mail"
set theNewMessage to make new outgoing message with properties {visible:true, subject:"Blah blah blah", content:"Hello World!"}
tell content of theNewMessage
tell theNewMessage
make new to recipient at end of to recipients with properties {address:"mymail@foobar.com"}
set theFont to "Calibri"
set font of content to theFont
set size of content to (14)
--error is here
set sourceFile to file "~:Desktop:SYS_Report.txt"
--error is here
tell content to make new attachment with properties {visible:true, file name:sourceFile as alias} at after the last paragraph
end tell
end tell
end tell
do shell script "rm ~/Desktop/SYS_Report.txt"
end if
if answer is equal to "Cancel" then
quit
end if
AppleScript: Version 2.3 (118)
Browser: Firefox 6.0.2
Operating System: Mac OS X (10.6)