Script email commands

Posted on
Tue Aug 01, 2006 7:07 pm
Lalit offline
Posts: 71
Joined: Jul 05, 2006
Location: Paris (France)

Script email commands

Hi,

How can I send an email using this action step and these commands ?

email to string -- (use if action type = sendEmail) the recipient's email address
email subject string -- (use if action type = sendEmail) the email subject
email body string -- (use if action type = sendEmail) the email body

I just want to integrate it on a long script...

Thanks for helping me !

Posted on
Wed Aug 02, 2006 7:07 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Script email commands

If you are wanting to send a dynamic email as part of an AppleScript, then I would suggest using the Apple Mail program to do it instead of Indigo. It is easier to do from AppleScript (I need to add an AppleScript verb to Indigo), and it will work with whatever SMTP settings you've defined in Mail.

Something like this:

tell application "Mail"
     set addrVar to "myemailaddress@mydomain.com"
     set subjectvar to "Device Status List"
     
     set bodyvar to "-----Device Dump-----" & return & return
     tell application "Indigo"
          set deviceList to every device
          repeat with currentDevice in devices
               tell currentDevice
                    set bodyvar to bodyvar & "Device: " & name & return
                    set bodyvar to bodyvar & "State: " & on state & return
                    set bodyvar to bodyvar & "Brightness: " & brightness & return & return
               end tell
          end repeat
     end tell
     
     set newMessage to (a reference to (make new outgoing message))
     tell newMessage
          make new to recipient at beginning of to recipients with properties {address:addrVar}
          set the subject to subjectvar
          set the content to bodyvar
     end tell
     
     send newMessage
end tell

Regards,
Matt

Posted on
Thu Mar 14, 2013 11:19 am
bmcgowan13 offline
Posts: 67
Joined: Jan 13, 2013

Re: Script email commands

Is there a way to capture and "use" the subject from the Apple Mail and use that in an Applescript?

I want to have try to get rid of some triggers (and learn to use AppleScript). I want to have a single script run when the email's sender is the alarm system (ourhouse@alarmco.com) but would like to use some nested if/then/else statements in lieu of individual triggers....

I'd have a rule in Apple Mail that would scan the email from the alarm company's email address, then if the subject of that email also contained "Disarmed" then activate a single AppleScript

tell application "IndigoServer"
If value of variable "EMailSubject" contains "William"
set value of variable "AlarmSet" to "False" as boolean
set value of variable "AlarmDisarmedBy" to "Bill" as string
Else
If value of variable "EMailSubject" contains "Patricia"
set value of variable "AlarmSet" to "False" as boolean
set value of variable "AlarmDisarmedBy" to "Aunt Pat" as string
Else
set value of variable "AlarmSet" to "False" as boolean
set value of variable "AlarmDisarmedBy" to "Unknown" as string
End if
End if
End if
end tell

Right now I have separate rules for all three situations and I'm using this to reduce triggers and get a better understanding of AppleScript.

But--is there a way to grab the subject of an incoming email? All the stuff online (here and other places I've googled is for setting the subject of outgoing emails...

Posted on
Fri Mar 15, 2013 8:58 am
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Script email commands

There's no way to pass data from a trigger to an AppleScript that's an action of the trigger.

I think you could write an AppleScript that's executed on each incoming email in the Mail application that could parse out the subject/body for information - then it could set variables in Indigo. I, however, and not an expert at Mail scripting so you'd need to figure that part out separately.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Mar 15, 2013 10:55 am
bmcgowan13 offline
Posts: 67
Joined: Jan 13, 2013

Re: Script email commands

Thanks Jay-

I'm not so sure that I can parse out the subject line.... I've been experimenting and searching online for a week or more but just can't figure out how to grab the subject line from AppleScript. There's a lot of great examples constructing and *sending* an email with a particular subject--but nothing on how to trap the subject and use it in an Applescript.

I can keep using the individual Mail Rules (as Mail can parse out the keywords in the email) and go from there.

Posted on
Mon Mar 18, 2013 3:36 pm
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Script email commands

I've never tried parsing incoming emails, but this post looks like a good place to start.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 30 guests