• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Mail rule script interacting with FileMaker
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Mail rule script interacting with FileMaker


  • Subject: Mail rule script interacting with FileMaker
  • From: Blaine <email@hidden>
  • Date: Sat, 06 Nov 2004 00:31:46 -0800

Hi,

I'm working on a script that is invoked via a mail.app rule and will look up
a customer's email address in a FileMaker database. If it finds a match, it
sends them their registration code(s) via a FileMaker script (sendmail
command). If it doesn't, it sends them a "not found" email which is
generated by the AppleScript.

It's all seems to be working, except for when the rule tries to process two
or more emails that contain valid customer email addresses (This happens
when we receive two requests at the same time). For example, with two
emails, Mail.app seems to not allow the FileMaker script to SendMail until
it hits the second email. So, the second person of the two people would get
their codes, but the first person doesn't.

I've been hitting my head against the wall for hours on this one. I consider
myself a newbie at this, and my script uses a lot (mostly) of example code.
I've pasted it below (please don't flame me too much if that's not kosher)
so those of you with the experience can probably look at it and say, "Why in
the world is he doing it that way?" Basically, any help you can provide
would be most appreciated.

It seems like mail.app is busy and won't accept the filemaker generated
emails until it's on the second of the two addresses.

Thanks!

Blaine

------------script-----------

using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule
        set messageList to {}
        say "starting script"
        tell application "Mail"
            repeat with eachMessage in theMessages
                say "setting email variable"
                copy sender of eachMessage to end of messageList
            end repeat
        end tell
        tell application "FileMaker Pro"
            try
                tell document "Customers.fp5"
                    activate
                    repeat with i in messageList
                        set email to i as string
                        set email2 to "=" & email as string -- the equal
sign is required for the filemaker search
                        do script FileMaker script "find" --this just
creates a fine command populated with the data below
                        set cell "Email" of request 1 of document 1 to
email2
                        set cell "Product" of request 1 of document 1 to "*"
--This is so empty "registrations" aren't included
                        set cell "Price" of request 1 of document 1 to "„0"
                        set cell "RegCode" of request 2 of document 1 to
"n/a"
                        set omitted of request 2 of document 1 to true
                        find
                        if (count of records of document 1) > 0 then
                            do script FileMaker script "registration code
Email" --this should send an email for each hit.
                        else
                            say "FileMaker didn't find it. Sending response
via mail."
                            tell application "Mail"
                                activate
                                set newMessage to make new outgoing message
with properties {subject:"Address not found", content:"We were unable to
find any orders placed with the email address: " & return & return & email &
return & "If you purchased with a different email address please send a new
registration code request using the other email address." & return & return
& "If your email address has changed, please submit an email chage request
here: <URL here>. After verfying your email change request, we will update
our database and send you your registration codes." & return & return &
"Regards," & return & return & "Blaine"}
                                tell newMessage
                                    set visible to true
                                    set theSender to
"email@hidden"
                                    set sender to theSender
                                    make new to recipient at end of to
recipients with properties {address:email, subject:"Registration code not
found", sender:"SplashData", reply to:"email@hidden"}
                                end tell
                                activate
                                send newMessage
                            end tell
                        end if
                    end repeat
                end tell
            on error
                say "Houston, we have a problem."
            end try
        end tell
    end perform mail action with messages
end using terms from



 _______________________________________________
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

  • Prev by Date: Re: Bridge anyone? [not off topic]
  • Next by Date: Re: HTML and Applescript?
  • Previous by thread: Orphaned disk error fixed in 10.3.6
  • Next by thread: Save a new file
  • Index(es):
    • Date
    • Thread