Real Software Forums
http://forums.realsoftware.com/

Zip file attached to Mail with AppleScript gets corrupted
http://forums.realsoftware.com/viewtopic.php?f=7&t=47370
Page 1 of 1

Author:  oleman108 [ Fri Mar 22, 2013 1:56 am ]
Post subject:  Zip file attached to Mail with AppleScript gets corrupted

In RS I compress a REALDatabase file using ZipMBS and save this file to the Documents folder. If I open this zip file manually, by double-clicking on it in Finder, then it unzips as expected. The Zip file is ok at this point of the process.

But in my RS program, I call an AppleScript to open Mail and attach the zip file to a new mail.

The Realbasic code:
Dim theSubject As String = "Backup of database " + dbFileNam
Dim theBody As String = "Database Last Modification Date : " + d.SQLDateTime
Dim theAttachment As String = SpecialFolder.Documents.Child(fName).NativePath
OSXSendMail(theSubject, theBody, theAttachment)

The AppleScript code:
on run {theSubject, theBody, theAttachment}
tell application "Mail"
set newMessage to make new outgoing message with properties {visible:true, subject:theSubject, content:theBody & return & return}
tell content of newMessage
make new attachment with properties {file name:theAttachment} at after the last paragraph
end tell
activate
end tell
end run

It seems to work as expected, but when I drag the attachment to the desktop (or also into the Documents folder) then I can no longer unzip this file by simply doubleclicking it. The error:
Image

However, I got "The Archive Browser" from the AppStore and with that utility it is possible to safely extract the original file.

But I need a solution which does not require the user to purchase a third party expander for zip files.

Somehow the AppleScript seems to alter the attachment. So maybe someone knows a safe way of attaching a RealSQLDatabase file to a mail and send it?

Author:  tempel [ Fri Mar 22, 2013 4:41 am ]
Post subject:  Re: Zip file attached to Mail with AppleScript gets corrupte

Send me a sample of the original and the problematic zip files and I'll find out what makes the second one not unzip.

Author:  oleman108 [ Fri Mar 29, 2013 5:10 am ]
Post subject:  Re: Zip file attached to Mail with AppleScript gets corrupte

tempel wrote:
Send me a sample of the original and the problematic zip files and I'll find out what makes the second one not unzip.
Done! Thanks a lot!

Author:  kevo [ Fri Mar 29, 2013 12:00 pm ]
Post subject:  Re: Zip file attached to Mail with AppleScript gets corrupte

I've run into something similar to this before where the solution ended up being a force quite of the appleeventsd process. I think the built in tool makes use of apple events as part of it's method of unzipping, and if that daemon gets hosed for some reason it won't work.

The times I've run into this it's been related to doing some scripting work with the AppleScript Editor, so it's a bit similar to your situation I think.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/