Re: Mail Quits Unexpectedly Using An AppleScript
Re: Mail Quits Unexpectedly Using An AppleScript
- Subject: Re: Mail Quits Unexpectedly Using An AppleScript
- From: kai <email@hidden>
- Date: Wed, 14 Dec 2005 00:12:35 +0000
On 12 Dec 2005, at 21:19, Ted wrote:
This might have something to do with a problem I've been having.
I've scripted FMPro 6 to attach a pdf to a Mail message via
AppleScript. It works fine except for the fact that Mail quits
unexpectedly about 95% of the time I run it. It doesn't matter if
I'm sending 1 pdf or 15 pdf's. It usually quits on me. Here's the
AppleScript portion:
-- 1st AS
-- This creates the pdf
set homePath to (path to home folder as text)
set theFilePath to homePath & cell "PDFLocation_TempPO_c" of
current record
tell app "FileMaker Pro" to set the newName to cell "Invoice_#" of
current record
tell app "Finder" to set the name of file theFilePath to newName &
".pdf"
FMPro pauses for 2 seconds here
-- 2nd AS
-- This sends the pdf
set theName to ""
set theAddress to "email@hidden"
set theSender to "email@hidden"
set theSubject to "P.O.#K5-7443"
set theBody to ""
set homePath to (path to home folder as text)
set theAttachment to (homePath & "business:pdfSent:K5-7443.pdf") as
alias
tell application "Mail"
set newMessage to make new outgoing message with properties ¬
{subject:theSubject, content:theBody}
tell newMessage
-- Default is false. Determines whether the compose window will
-- show on the screen or whether it will happen in the
background.
set visible to true
set sender to theSender
make new to recipient at end of to recipients with properties ¬
{name:theName, address:theAddress}
tell content
-- Position must be specified for attachments
make new attachment with properties {file
name:theAttachment} at ¬
after the last paragraph
end tell
end tell
send newMessage
end tell
I added the 2 second pause between the scripts thinking that might
help, but it doesn't. Am I doing something wrong or could there be
a bug in Mail?
I'm not so sure this is connected to the behaviour I was describing
previously, Ted.
I've tried running your second script (with variables appropriately
amended, of course), and it works fine here. If I were you, I'd try
something similar - running it from a script editor, rather than from
FileMaker. If that works, try running the same hard-coded script from
within FileMaker. And if that works, you may need to go back to check
your FileMaker routine and cell data. (Incidentally, from here, the
first script doesn't look as if it actually creates a pdf - although
I'm not sure that's part of the problem, either.)
The trick here is to try and isolate exactly where the issue arises.
If you can narrow this down a bit, the cause of the problem (and
hopefully a solution) may become more apparent.
Good luck.
:-)
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden