Help converting simple Mail Applescript to python

Posted on
Thu Oct 22, 2020 6:32 pm
joekewe offline
Posts: 8
Joined: May 27, 2013

Help converting simple Mail Applescript to python

Can someone help me convert this AppleScript to python so I can move to Indigo 7.4?

Code: Select all
property emailAddress : “bob@mac.com"
property emailSubject : "Office Alarm!"
property newline : ASCII character (10)

if value of variable "emailBob” < 50 then
        set emailBody to “Office alarm: " & value of variable "alarmCause" & newline
        set emailBody to emailBody & "Current time: " & time string of (current date) & newline
        send email to emailAddress with subject emailSubject with body emailBody
end if

Thanks,

Joe

Posted on
Thu Oct 22, 2020 8:17 pm
FlyingDiver offline
User avatar
Posts: 5350
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Help converting simple Mail Applescript to python

Have you looked at the instructions in the Wiki on sending emails?

https://wiki.indigodomo.com/doku.php?id ... l_settings

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Fri Oct 23, 2020 3:46 pm
joekewe offline
Posts: 8
Joined: May 27, 2013

Re: Help converting simple Mail Applescript to python

FlyingDiver wrote:
Have you looked at the instructions in the Wiki on sending emails?

https://wiki.indigodomo.com/doku.php?id ... l_settings


Yes. If I am not mistaken, Indigo's built-in email capability can only send pre-written text. It looks like you are the author of "Better Email," which is... better, because it lets you send Indigo variables and device states, but still not the current time like my little AppleScript does.

I was also hoping to use this as my intro to python scripting Indigo - to learn how to define variables and control external software like Mail. Any help appreciated.

Posted on
Fri Oct 23, 2020 4:25 pm
FlyingDiver offline
User avatar
Posts: 5350
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Help converting simple Mail Applescript to python

You can use an Indigo action to put the current time into a variable, then include that variable in the email. Check under "Variable Actions".

The Better Email plugin wiki has an example script for sending an email: https://github.com/FlyingDiver/Indigo-B ... etterEmail

Combine that with a line of code to get the current time in a string: https://www.programiz.com/python-progra ... rrent-time

Actually controlling the Mail application without AppleScript is pretty much impossible. It's easier to use the native email sender or the BE plugin.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest