Script to send email with attachments

6,178 views
Skip to first unread message

baudi

unread,
Oct 25, 2010, 10:28:39 AM10/25/10
to Tasker
I've written an SL4A Python script that lets you send an email with
attachments without going through the compose prompt.

Details here: http://tasker.wikidot.com/sl4a

TW

unread,
Oct 25, 2010, 2:56:33 PM10/25/10
to Tasker
this is very nice!
bookmarked it and will have a play with it after I finished my other
Tasker related stuff :)

Zach

unread,
Oct 25, 2010, 12:11:06 PM10/25/10
to Tasker
Can you send me a walk through for this. I am unsure how to go about
setting this up in tasker. I have the python file and sl4a installed.

baudi

unread,
Oct 25, 2010, 6:14:53 PM10/25/10
to Tasker
I modified the wiki page. Try it now.

iphone2n1

unread,
Oct 25, 2010, 10:19:55 PM10/25/10
to Tasker
thanks baudi. Now my favorite programming language has moved onto yet
another place in my life. :-D Python rules!

RogueSpear

unread,
Oct 25, 2010, 11:08:17 PM10/25/10
to Tasker
Thank you a million times over for posting this! I badly needed a
real example of an SL4A solution to get me going on fully see the
usefulness. From the looks of it this could extend my Tasker
obsession into uncharted territory.

baudi

unread,
Oct 26, 2010, 8:47:46 AM10/26/10
to Tasker
> thanks baudi. Now my favorite programming language has moved onto yet
> another place in my life. :-D Python rules!

You're welcome. I'm new to Python, and I'm still learning. I imagine
that there are better ways to do what I've done in that script, so if
you have any recommendations for changes or improvements, I'd
appreciate hearing them.

Filmmakerc14

unread,
Oct 26, 2010, 9:39:40 PM10/26/10
to Tasker
Hello,
I have been trying to get this to work for a few days and have been
unsuccessful in every way I try.
How exactly is it setup? I read the wiki so I believe you write the
tasker task like:
Set Variable: %EMAIL_To to em...@gmail.com
*You do this for every variable you would use.
Then you have:
Run Script: sendemailA.py and Pass Variables %EMAIL_USER, %EMAIL_PSWD,
etc.

Is this correct so far?
The problem is when I run the script, I keep getting an Invalid Syntax
error.

It shows this try: smtpOj = smtplib.SMTP('smtp.aol.com',25)
smtpObj.login('my username','my password') smtpObj.sendmail(sender,
receivers, message)*

Where the * is, the little arrow in the terminal is pointing to. Also,
my username and my password are substituted, they look like
filmmakerc14 and 123456 for example.

What seems to be the problem? I checked for an extra space or anything
simple but I got nothing. Any ideas?

baudi

unread,
Oct 26, 2010, 9:50:39 PM10/26/10
to Tasker
You tried to modify it to work with an aol address, right? I don't
know what the aol server expects in terms of port numbers, ssl, etc.,
but it's almost certainly not the same as what gmail expects.

Sorry, but I guess you're on your own with figuring out the correct
aol protocol needed. If you get it working, you might want to post the
answer so others can make it work, too.

Filmmakerc14

unread,
Oct 27, 2010, 11:01:41 AM10/27/10
to Tasker
I didn't modify anything. Unless I guess mabey sending it to an aim
email is the problem? I left the script as is.
Ill try sending to a gmail in a minute.

baudi

unread,
Oct 27, 2010, 11:06:05 AM10/27/10
to Tasker
Hmmm. Well, in that case, I wonder if you have a special character in
your user id or password that's confusing Tasker and/or Python. If you
use single or double quotes or % or some other special characters in
your password, you might try changing it to just letters and numbers
temporarily and see if that fixes it.
Message has been deleted

Filmmakerc14

unread,
Oct 27, 2010, 11:09:02 AM10/27/10
to Tasker
Both my email and pass are standard characters (numbers and letters).

Chris

unread,
Oct 28, 2010, 1:29:34 AM10/28/10
to Tasker
Works perfect, great work.

On Oct 25, 4:28 pm, baudi <dch...@gmail.com> wrote:

Filmmakerc14

unread,
Oct 28, 2010, 1:58:27 AM10/28/10
to Tasker
Hi,
Just wondering, do you have any other accounts besides a google on
your phone?
I have been unable to get it to work so I am trying to figure out why.
Thanks

Chris

unread,
Oct 28, 2010, 3:21:33 AM10/28/10
to Tasker
Are you getting any error messages?

Filmmakerc14

unread,
Oct 28, 2010, 3:25:41 AM10/28/10
to Tasker
Yes, the one listed above in another responce.
For some reason it changes from gmail to aim to try to send the
message.

Chris

unread,
Oct 28, 2010, 7:08:21 AM10/28/10
to Tasker
Ah I see, I only have Gmail and exchange set up on my device, so I'm
not sure why it switches you to the AIM one, sorry.
I have only tried sending from Gmail to Gmail

baudi

unread,
Oct 28, 2010, 7:47:10 AM10/28/10
to Tasker
Filmmakerc14,

It's not switching to aim, it's switching to aol. Did you try the
suggestion I made in the private email to you?

There's simply no way that a random bug is causing a string constant
with a value of "smtp.gmail.com" to change to "smtp.aol.com". If it
were changing to "flkajsd;lajk" then maybe, but not to another string
that kind of makes sense in the context. I think you are not running
the sendemailA.py script, but some other script.

Sorry you're having problems with it.

baudi

unread,
Oct 28, 2010, 10:27:00 AM10/28/10
to Tasker
Just to clarify how this script works:

The script stands on its own without reference to other data or
applications. It does not depend on or try to use other email clients
or accounts you may already have set up on your phone. It doesn't know
about those other accounts, nor does it care what they are.

It depends on the user passing it parameters containing valid user id
and password for a gmail account.

It doesn't allow you to send email FROM non-gmail accounts in it
current incarnation.

It does, of course, allow you to send email TO any other valid email
address, not just gmail addresses.

Message has been deleted
Message has been deleted

Filmmakerc14

unread,
Oct 28, 2010, 11:14:35 AM10/28/10
to Tasker
Sorry for the confusion.
After deleting all my extra email scripts I got it to work.
Although it said the correct name, it must have cross linked the
script name to another script.
Thanks for the help.

Joris Boerboom

unread,
Oct 30, 2010, 7:55:02 PM10/30/10
to Tasker
Can someone point out what I am doing wrong? Steps:

-Installed SL4A
-Installed the Python interpreter
-Downloaded sendemailA.py , then created a directory "ase/scripts" so
I can select the script in Tasker
-I then filled this in at the Pass Variables section:
%EMAIL_NAME mynamehere, %EMAIL_USER myusername, %EMAIL_PSWD passhere,
%EMAIL_TO mymailtotest, %EMAIL_SUBJECT test, %EMAIL_BODY time to test
this

Terminal is ticked off. When I do Test in Tasker, it is launching the
script (I think) because briefly the button "kill" appears in the
bottom right of my screen. But afterwards I do not receive any email.

baudi

unread,
Oct 31, 2010, 10:53:44 AM10/31/10
to Tasker
sendemailA.py should be installed in sl4a/scripts not ase/scripts.
Also, you need to be running the latest version of Tasker.

Where did you read that it should be installed in ase/scripts? ASE is
the old name for SL4A, and some of the documentation still refers to
ASE. Let me know where you saw it and I'll see if I can get somebody
to change it.

Joris Boerboom

unread,
Nov 1, 2010, 2:28:08 PM11/1/10
to Tasker
Thanks for your reply. This is what I did now:

-Upgraded tasker to 1.0.12
-Deleted the ASE directory and installed sendemailA.py in sl4a/scripts
-I then configured the tasker task as I did in the above part.

The script is now actually running, it wasnt before. But I get the
error: EMAIL_USER missing
What am I doing wrong? Do I have to put the variables between quotes?
For example: %EMAIL_NAME 'John Smit' ? My username contains only
letters and no spaces, so it shouldnt matter for the EMAIL_USER
variable.

Joris

oh p.s. I found the ASE part here: http://tasker.wikidot.com/sendemail
I originally started with that tutorial, I figured it wouldnt be a
problem.

baudi

unread,
Nov 1, 2010, 4:03:28 PM11/1/10
to Tasker
Follow these instructions: http://tasker.wikidot.com/email

Filmmakerc14

unread,
Nov 1, 2010, 4:33:15 PM11/1/10
to Tasker
Hi
I think you need to add another part into your tasker task.
Before you tell it to run the scrit, set the variables to your
information.
So you select add variable, EMAIL_NAME, then in the box, enter your
name.
do this for all the credentials and in the run script part, it should
look like:
EMAIL_NAME,EMAIL_USER...

mac

unread,
Nov 27, 2010, 7:11:28 PM11/27/10
to Tasker
I'm having trouble with Tasker itself, is this where I should ask
about it? When I hit the little magnifying glass to browse to
sendemailA.py, I get the error that "ASE script dir doesn't exist or
isn't a dir." How can I fix this?

baudi

unread,
Nov 28, 2010, 10:43:52 AM11/28/10
to Tasker
Are you using the latest version of Tasker?

Did you follow the instructions here? http://tasker.wikidot.com/sl4a

James

unread,
Dec 9, 2010, 11:47:30 PM12/9/10
to Tasker
Just wondering what you did as I also have the same error message :(

baudi

unread,
Dec 10, 2010, 7:25:07 AM12/10/10
to Tasker
Are you using the latest version of Tasker?
Did you follow the instructions here? http://tasker.wikidot.com/sl4a

Erwin Tschirk

unread,
Feb 1, 2011, 10:59:51 AM2/1/11
to Tasker
i make a different script, if i have more freetime, i'll paste it
somewhere ...
i haven't tested it, but should work in theory.
i'm more a friend of XDA, maybe i poste it there an thread about this
- if it is ok for all guys ..
cu

# see: princip is simular to scripts on
# http://tasker.wikidot.com/sl4a (install of sla4 + python)
# http://tasker.wikidot.com/email
# http://groups.google.com/group/tasker/browse_thread/thread/e5be4f150d9faaab
# but i use following parameters, which can be define and customize in
"Tasker"
# do create these parameters (-> Tasker -> tasks -> variable ->
variable set)
# there you can combine all parameters to one of this (specially the
subject and body text of email is helpful)
#
# parameter delimited via ","
# 1.) parameter: %SMTP_MAILSERVER_ADDRESS (dns or ip address)
# 2.) parameter: %SMTP_MAILSERVER_PORT (vlid port number)
# 2.) parameter: %SMTP_MAILSERVER_SECURITY (0=off, 1=ssl, 2=tls)
# 3.) parameter: %SMTP_USERNAME
# 4.) parameter: %SMTP_PASSWORD
# 5.) parameter: %MAIL_SENDER_NAME
# 5.) parameter: %MAIL_SENDER_EMAIL
# 6.) parameter: %MAIL_RECEIVER_EMAIL
# 7.) parameter: %MAIL_SUBJECT
# 8.) parameter: %MAIL_BODY
# 9.) parameter: %MAIL_ATTACHMENT (files can be added - not fully
tested, because don'T use it - but should work for multiple, too)

###########################################################################################

import os
import glob
import mimetypes
from email import encoders
from email.mime.audio import MIMEAudio
from email.mime.base import MIMEBase
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

def attach_files(msg, attachements):
for attachment in attachments:
attachment = attachment.strip()
for path in glob.glob(attachment):
filename = os.path.basename(path)
if not os.path.isfile(path):
continue
# Guess the content type based on the file's extension.
Encoding
# will be ignored, although we should check for simple things
like
# gzip'd or compressed files.
ctype, encoding = mimetypes.guess_type(path)
if ctype is None or encoding is not None:
# No guess could be made, or the file is encoded (compressed),
so
# use a generic bag-of-bits type.
ctype = 'application/octet-stream'
maintype, subtype = ctype.split('/', 1)
if maintype == 'text':
fp = open(path)
# Note: we should handle calculating the charset
part = MIMEText(fp.read(), _subtype=subtype)
fp.close()
elif maintype == 'image':
fp = open(path, 'rb')
part = MIMEImage(fp.read(), _subtype=subtype)
fp.close()
elif maintype == 'audio':
fp = open(path, 'rb')
part = MIMEAudio(fp.read(), _subtype=subtype)
fp.close()
else:
fp = open(path, 'rb')
part = MIMEBase(maintype, subtype)
part.set_payload(fp.read())
fp.close()
# Encode the payload using Base64
encoders.encode_base64(part)
# Set the filename parameter
part.add_header('Content-Disposition', 'attachment',
filename=filename)
msg.attach(part)

def sendemail(py_smtp_mailserver_address, py_smtp_mailserver_port,
py_smtp_mailserver_security, py_smtp_username, py_smtp_password,
py_mail_sender_name, py_mail_sender_email, py_mail_receiver_email,
py_mail_subject, py_mail_body, py_mail_attachment):
import smtplib

# DON'T CHANGE THIS!
# ...unless you're rewriting this script for your own SMTP server!
smtp_server = py_smtp_mailserver_address
smtp_port = py_smtp_mailserver_port

# Build an SMTP compatible message
msg = MIMEMultipart()
msg['Subject'] = py_mail_subject
msg['To'] = py_mail_receiver_email
msg['From'] = py_mail_sender_email
msg['From'] = py_mail_sender_name + " <" + py_mail_sender_email +
">"
msg.attach(MIMEText(py_mail_body, 'plain'))
attach_files(msg, py_mail_attachment)

#py_smtp_mailserver_security
# Attempt to connect and send the email
try:
smtpObj = '' # Declare within this block.
# Check for SMTP over SSL by port number and connect accordingly
if( py_smtp_mailserver_security == 1):
smtpObj = smtplib.SMTP_SSL(smtp_server,smtp_port)
else:
smtpObj = smtplib.SMTP(smtp_server,smtp_port)
smtpObj.ehlo()
# StartTLS if using the default TLS port number
if(py_smtp_mailserver_security == 2):
smtpObj.starttls()
smtpObj.ehlo
# Login, send and close the connection.
smtpObj.login(py_smtp_username, py_smtp_password)
smtpObj.sendmail(py_mail_sender_email, py_mail_receiver_email,
msg.as_string())
smtpObj.close()
return 1 # Return 1 to denote success!
except Exception, err:
# Print error and return 0 on failure.
print err
return 0

import sys
import android

droid = android.Android()

try:
py_smtp_mailserver_address = droid.getIntent().result[u'extras']
[u'SMTP_MAILSERVER_ADDRESS']
except:
py_smtp_mailserver_address = ''
sys.exit(1)
try:
py_smtp_mailserver_port = droid.getIntent().result[u'extras']
[u'%SMTP_MAILSERVER_PORT']
except:
py_smtp_mailserver_port = 25
try:
py_smtp_mailserver_security = droid.getIntent().result[u'extras']
[u'%SMTP_MAILSERVER_SECURITY']
except:
py_smtp_mailserver_security = 0
try:
py_smtp_username = droid.getIntent().result[u'extras']
[u'%SMTP_USERNAME']
except:
py_smtp_username = ''
sys.exit(1)
try:
py_smtp_password = droid.getIntent().result[u'extras']
[u'%SMTP_PASSWORD']
except:
py_smtp_password = ''
try:
py_mail_sender_name = droid.getIntent().result[u'extras']
[u'%MAIL_SENDER_NAME']
except:
py_mail_sender_name = ''
try:
py_mail_sender_email = droid.getIntent().result[u'extras']
[u'%MAIL_SENDER_EMAIL']
except:
py_mail_sender_email = ''
try:
py_mail_receiver_email = droid.getIntent().result[u'extras']
[u'%MAIL_RECEIVER_EMAIL']
except:
py_mail_receiver_email = ''
try:
py_mail_subject = droid.getIntent().result[u'extras']
[u'%MAIL_SUBJECT']
except:
py_mail_subject = ''
try:
py_mail_body = droid.getIntent().result[u'extras'][u'%MAIL_BODY']
except:
py_mail_body = ''
try:
py_mail_attachment = droid.getIntent().result[u'extras']
[u'%MAIL_ATTACHMENT']
py_mail_attachment = py_mail_attachment.split(',')
except:
attachments = ''

# Send email
if (sendemail(py_smtp_mailserver_address, py_smtp_mailserver_port,
py_smtp_mailserver_security, py_smtp_username, py_smtp_password,
py_mail_sender_name, py_mail_sender_email, py_mail_receiver_email,
py_mail_subject, py_mail_body, py_mail_attachment)):
sys.exit(0)
else:
# Exit with error if email is not sent successfully
droid.makeToast('email failed')
sys.exit(1)

Nelson

unread,
Mar 10, 2011, 11:55:38 AM3/10/11
to Tasker
When I try to run the script, I get the error "no ssl support included
in this python".

I have Python 2.6.2 installed, which I downloaded from here:

http://code.google.com/p/android-scripting/wiki/InstallingInterpreters

Any ideas how to fix this?

On Feb 1, 10:59 am, Erwin Tschirk <erwin.tsch...@gmail.com> wrote:
> i make a different script, if i have more freetime, i'll paste it
> somewhere ...
> i haven't tested it, but should work in theory.
> i'm more a friend of XDA, maybe i poste it there an thread about this
> - if it is ok for all guys ..
> cu
>
> # see: princip is simular to scripts on
> #http://tasker.wikidot.com/sl4a(install of sla4 + python)
> #http://tasker.wikidot.com/email
> #http://groups.google.com/group/tasker/browse_thread/thread/e5be4f150d...

stefano galletti

unread,
Jun 30, 2012, 12:48:56 PM6/30/12
to tas...@googlegroups.com
my mistake...wrong phyton installation...now run script works...but no email was sended, user name and password i've checked are correct,username requires "@gmail.com"? I've tryied both by the way but no sending

Il giorno sabato 30 giugno 2012 17:56:04 UTC+2, stefano galletti ha scritto:
Hi I created a sendemail task that passes all the parameters but when I use tasker run script after few seconds get a popup : SL4A ABORTED.

I put sendemaiA.py in sl4a folder, but if I open sl4a app, It doesn't recognize the script... could you help me? regards

baudi

unread,
Jul 13, 2012, 9:49:35 AM7/13/12
to tas...@googlegroups.com
My tasker does not refresh the CNUM and the CNAME values. It is stuck on a old set of values. How do I solve this ?

Sorry, I don't understand what you mean. 

dlx29

unread,
Jul 21, 2012, 8:41:32 AM7/21/12
to tas...@googlegroups.com
I found the issue, it was a typo in the variable pass.

It works great! When I lay the phone on it's left side it records audio. When I pick it up, it stops recording and emails me the audio file.

Dale Massey

unread,
Aug 2, 2012, 6:58:03 AM8/2/12
to tas...@googlegroups.com

Have you tried removing and reinstalling SL4A and Python as described. In the Wiki links?

http://tasker.wikidot.com/email

When you install Python open it from the app drawer and install the interpreters.

Hope that helps. If not, then try reinstalling SL4A.

On Aug 2, 2012 2:11 AM, "Mark Serena" <markj...@gmail.com> wrote:
I had this working a few weeks a little while ago, but now for some reason it has stopped. When i enable terminal in the run SL4A script, i get the error 

no module named _socket after it tries to import mimetypes
what could of gone wrong in that time? Possibly an update or something I've done?

Thanks for hints

baudi

unread,
Aug 2, 2012, 9:02:30 AM8/2/12
to tas...@googlegroups.com
After you install SL4A, Py4A, and the sendemailA script, there are no updates unless you do them yourself. 

The mimetypes error could possibly happen because of a file you were trying to attach. Not sure. Try it again and just attach a small text file and see it it still fails.

Mark Serena

unread,
Aug 3, 2012, 1:34:08 AM8/3/12
to tas...@googlegroups.com
yup...reinstall fixed that. thanks guys.

Dale Massey

unread,
Aug 3, 2012, 7:54:44 AM8/3/12
to tas...@googlegroups.com

Great! Glad to help!

Dale Massey

unread,
Aug 12, 2012, 7:51:34 AM8/12/12
to tas...@googlegroups.com

First off I would download the file from the web straight to your phone. Then move it from the downloads folder to sl4a scripts folder using something like root explorer (free on the play store)

Line 85 is going to be around the mail code, are you sending it to a Gmail account?  Also check your variables a typo will break the whole thing.

Dale

On Aug 12, 2012 1:19 AM, "JvK" <jvkin...@gmail.com> wrote:
i'm desperate...I followed all steps...have Python, SL4A.....sendemailA.py is in the SL4A script folder, sena ll the correct parameters, but I can't get Tasker to email the pic.  Double-checked everything.  The only thing I was wondering if it matters how the sendemailA.py script looks like..for instance, wrapped or does it have the be in a line by line format?  I copied the line by line script from wordpad to my phone via my computer, and I get a syntax error in line 85, but the script is exactly as the sendemailA.py script you find on the web.  Any suggestions?

JvK

unread,
Aug 12, 2012, 8:49:55 AM8/12/12
to tas...@googlegroups.com

I downloaded the file now directly to my phone and getting the same error. I am sending it from a gmail account to another gmail account. My phone is not rooted. Not sure if that is needed. 

Dale Massey

unread,
Aug 12, 2012, 8:59:00 AM8/12/12
to tas...@googlegroups.com

Don't think it has to be rooted. Maybe baudi will correct me. 

I had issues when trying to set it the first time turned out to be an error in my variable.

What exactly throws the error sl4a?

You do have python installed correctly?  After you download it you have to find it in your app drawer and install the interpreters.

Dale

JvK

unread,
Aug 12, 2012, 9:44:04 AM8/12/12
to tas...@googlegroups.com

This is what it all looks like. Picture is taken, but no email, not even one without an attachment.

Screenshot_2012-08-12-09-42-42.png

JvK

unread,
Aug 12, 2012, 9:48:19 AM8/12/12
to tas...@googlegroups.com

I installed Python 3

Screenshot_2012-08-12-09-47-30.png

JvK

unread,
Aug 12, 2012, 9:50:36 AM8/12/12
to tas...@googlegroups.com

Does this look like it is supposed to look?

Screenshot_2012-08-12-09-49-29.png

JvK

unread,
Aug 12, 2012, 9:55:11 AM8/12/12
to tas...@googlegroups.com

Not sure if you can read this. The response I get when i run the script

Screenshot_2012-08-12-09-51-51.png

Dale Massey

unread,
Aug 12, 2012, 9:59:55 AM8/12/12
to tas...@googlegroups.com

Here's a pic of mine.

Perhaps you should only include the user name not the complete email (@gmail.com) on the user variable.

Also make sure the attached file location is indeed in /mnt/sdcard...
and not /sdcard.....

Screenshot_2012-08-12-08-53-06.png

Dale Massey

unread,
Aug 12, 2012, 10:03:58 AM8/12/12
to tas...@googlegroups.com

I can zoom in and read it. I will try to reproduce the error on mine...

But gotta go fix the  kids some pancakes right now.....

Dale

Dale Massey

unread,
Aug 12, 2012, 10:17:02 AM8/12/12
to tas...@googlegroups.com

This is where I have mine. See the  location path at the top.

On Aug 12, 2012 8:50 AM, "JvK" <jvkin...@gmail.com> wrote:
Screenshot_2012-08-12-09-15-15.png

Dale Massey

unread,
Aug 12, 2012, 10:34:11 AM8/12/12
to tas...@googlegroups.com

A syntax error would indicate an error in the source of the script.

Look at this screenshot. Line 85 is the one below (smtp port == 465)
Does yours look exactly like this?

Screenshot_2012-08-12-09-30-30.png

baudi

unread,
Aug 12, 2012, 11:12:31 AM8/12/12
to tas...@googlegroups.com
Python 3 is not backwards-compatible with Python 2, which is what the script is written for. You have to install this one instead.  http://code.google.com/p/python-for-android/downloads/detail?name=PythonForAndroid_r5.apk 

On Sunday, August 12, 2012 9:48:19 AM UTC-4, JvK wrote:

I installed Python 3

baudi

unread,
Aug 12, 2012, 11:23:25 AM8/12/12
to tas...@googlegroups.com
I have changed the wiki to reflect the fact that the code is written for Python 2. 6.2, not Python 3.

Dale

unread,
Aug 12, 2012, 11:26:09 AM8/12/12
to tas...@googlegroups.com
Nice! 


Sent from my iPad

JvK

unread,
Aug 12, 2012, 11:59:21 AM8/12/12
to tas...@googlegroups.com

Thanks Baudi and Dale. Looks like installing 2.62 did the trick. Still messing around with it, si I might call on you later!   :-)

baudi

unread,
Aug 13, 2012, 11:24:24 AM8/13/12
to tas...@googlegroups.com
Would having special characters like ", !, $, £, % etc. in your Gmail password stop the script from working?
Possibly 

Also, I have added these as variables in Tasker but the script doesn't come up. I have had to edit the actual 'sendemailA.py' script in SL4A, is that a good idea?
No, it's not a good idea. And I'm not sure what you mean by "come up." Nothing comes up.

baudi

unread,
Aug 14, 2012, 8:39:53 AM8/14/12
to tas...@googlegroups.com
You need to get an application specific password and use that instead of your normal password. You can do that here https://www.google.com/accounts/IssuedAuthSubTokens


On Monday, August 13, 2012 4:18:12 PM UTC-4, tholmes1 wrote:
I used the script and it works perfectly for me but I recently enabled Google's 2-step verification which stopped the script from working automatically. I turned it off and it's working fine again but my question is is there a way to send the email from another account besides gmail or should I create a dummy account for this? anything besides changing the script?


leopheard

unread,
Aug 14, 2012, 8:52:19 AM8/14/12
to tas...@googlegroups.com
Okay, I have a rooted Galaxy S3 with Tasker 1.3.1m installed, Python 2.6.2 and SL4A r6.

I have no knowledge of programming so this is probably why this is so hard.

I have the sendemailA.py script in the script folder of SL4A. I am trying to make the phone look for a keyword in either an email or SMS so it monitors the screen unlock feature in order to take a photo of a potential thief if the phone is lost/stolen and then email it to me. Another way would be to use Dropbox but I'm not sure about this as I'd eventually like to tag the photo with the GPS of the phone, but Dropbox renames the files. I'd also have to alter the auto-upload settings to upload not only on wifi (I'm sure this is doable with Tasker). Anyway...

I have managed all of this process using Tasker, but can't get the sendemail.py Python script to do ANYTHING:


What am I doing wrong? Sorry to be a pain, but I have a lot of respect for anyone who can do programming, as it's like trying to decrypt a puzzle with no clues!

Also, the variables I have set for this task (in the far right tab) keep resetting themselves. I thought tasks obtain the info from these variables but do not alter them? I have similar tasks to this, but have stopped them for now.

Any help would be greatly appreciated as this is driving me mad.

baudi

unread,
Aug 14, 2012, 6:05:54 PM8/14/12
to tas...@googlegroups.com
Variables don't reset themselves. You are setting them somewhere, and you've forgotten that you are doing it. You need to set them explicitly with Variable/Set before you call sendemailA.py. 

If it still doesn't work after you make sure you are doing that, then tick the Terminal box and attach the screen that results after you execute the task.


baudi

unread,
Aug 15, 2012, 10:33:22 AM8/15/12
to tas...@googlegroups.com
One thing to check is whether you're doing a Variable/Clear anywhere without mentioning a particular variable. In that case, ALL variables are cleared.

Bubba

unread,
Sep 1, 2012, 12:41:33 AM9/1/12
to tas...@googlegroups.com
Just started trying to get this set up, but I can't get the attachments working. I'm setting up the textmessagetotakeapictureandemailittomyself routine and can't get the photos to attach. Everything else was a breeze to this point.

So far I've gotten it to work once, but when I repeated the task without making any changes it doesn't anymore. I set up Tasker to zip the jpgs and now it will send the zip file, but not the JPG. I thought size might be an issue, but even a 50kb jpg doesn't work, while a 50kb zip will.

I have %EMAIL_ATTACH set to /sdcard/DCIM/Tasker/front.jpg
Message has been deleted

Edouard Maza

unread,
Nov 25, 2012, 5:39:55 AM11/25/12
to tas...@googlegroups.com
Hi, i'm using this great script and it works but I'm french and uses ISO-8852-1, so I get an error for accented charater for exemple ( I'm setting %EMAIL_BODY to %SMSRB ). I don't know Pithon at all, so I'm wondering how to convert the string of character?

Pete S

unread,
Dec 19, 2012, 9:49:06 PM12/19/12
to tas...@googlegroups.com
I think I have everything correct but the email isn't sending. No error message. Any help is greatly appreciated.

Profile: Backup Profile (26)
Time: From 23:23 Till 23:24
Enter: Send Backup (31)
A1: Run SL4A Script [ Name:sendemailA.py Terminal:Off Pass Variables:Pete, GmailAddress, passcode, em...@gmail.com, tablet, backup, /Tasker/userbackup.xml ]

Matt R

unread,
Dec 27, 2012, 12:38:53 PM12/27/12
to tas...@googlegroups.com
It goes in sl4a/scripts

Matt

Leo Dantas

unread,
Dec 27, 2012, 7:25:30 PM12/27/12
to tas...@googlegroups.com
Thanks Matt!

I followed all instructions, but the action doesn't send the email. No error returns.

Any idea?



2012/12/27 Matt R <matthew.r...@gmail.com>
It goes in sl4a/scripts

Matt

GermainZ

unread,
Dec 27, 2012, 7:33:03 PM12/27/12
to tas...@googlegroups.com
That means it's completing correctly. You probably passed wrong parameters.

Leo Dantas

unread,
Dec 27, 2012, 7:53:14 PM12/27/12
to tas...@googlegroups.com
I think the problem is the blank variables.

What do I pass the optional variables (evan not set)?

Does it should work... Pass variables: %EMAIL_USER, %EMAIL_PSWD, %EMAIL_TO ???

Thanks



2012/12/27 GermainZ <germ...@gmail.com>

Leo Dantas

unread,
Dec 27, 2012, 8:19:03 PM12/27/12
to tas...@googlegroups.com
I think the script is not starting, because I wrote any stuff on Pass Variables and no erro message returns.

Any help?

2012/12/27 Leo Dantas <leoda...@gmail.com>

GermainZ

unread,
Dec 27, 2012, 8:21:13 PM12/27/12
to tas...@googlegroups.com
Which version of Python are you using?

Leo Dantas

unread,
Dec 27, 2012, 8:27:35 PM12/27/12
to tas...@googlegroups.com
I think it's version 5, but I am not sure.

Where can I check the python version?

Thanks

2012/12/27 GermainZ <germ...@gmail.com>

Leo Dantas

unread,
Dec 27, 2012, 8:28:51 PM12/27/12
to tas...@googlegroups.com

Brian Myers

unread,
May 9, 2013, 9:35:47 AM5/9/13
to tas...@googlegroups.com
I got it to work!  My directory explicitly says my internal storage is called sdcard0 - so it reads something like this: sdcard0/DCIM/Tasker/lksjdflkdsjf.jpg

In the tasker profile, I changed the directory to sdcard/DCIM/Tasker/lskjdflijwlk.jpg and it worked.  But I had tried that in the beginning, and it didn't work, so perhaps something I did in the hour I was messing with it before I tried it again contributed to the success....

Good luck. 



Brian Myers
College of Medicine - MD, 2015
Chair - OSU/COTA Partnership Advisory Committee
The Ohio State University


On Thu, May 9, 2013 at 1:26 AM, Eng. Khalil Qatu <khali...@gmail.com> wrote:
Same thing happens with me 

On Wednesday, May 8, 2013 6:03:09 PM UTC+3, Brian Myers wrote:
I'm good with tasker and SL4A.  The scripts, variables, and everything else haven't given me any trouble.

I get the email, but with no attachment.  I have triple checked my photo locations on my phone and then in tasker's %EMAIL_ATTACH.  Still no luck.

Any ideas?

On Monday, October 25, 2010 10:28:39 AM UTC-4, baudi wrote:
I've written an SL4A Python script that lets you send an email with
attachments without going through the compose prompt.

Details here: http://tasker.wikidot.com/sl4a

--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/5b5PFQ2fqqs/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Message has been deleted
Message has been deleted

Mike L

unread,
Jun 2, 2013, 9:40:03 PM6/2/13
to tas...@googlegroups.com
Gmail Send (10)
A1: Variable Set [ Name:%EMAIL_USER To:Your Email Address without @gmail.com Do Maths:Off Append:Off ] 
A2: Variable Set [ Name:%EMAIL_PSWD To:Your Email Password Do Maths:Off Append:Off ] 
A3: Variable Set [ Name:%EMAIL_TO To:Email Address Sending To Do Maths:Off Append:Off ] 
A4: Variable Set [ Name:%EMAIL_SUBJECT To:Email Subject Here Do Maths:Off Append:Off ] 
A5: Variable Set [ Name:%EMAIL_BODY To:Email Text Here Do Maths:Off Append:Off ] 
A6: Variable Set [ Name:%EMAIL_ATTACH To:Attachment Location Here Do Maths:Off Append:Off ] 
A7: Run SL4A Script [ Name:sendemailA.py Terminal:Off Pass Variables:%EMAIL_USER,%EMAIL_PSWD,%EMAIL_TO,%EMAIL_ATTACH,%EMAIL_SUBJECT,%EMAIL_BODY Continue Task After Error:On ] 
A8: Variable Clear [ Name:%EMAIL_SUBJECT Pattern Matching:Off ] 
A9: Variable Clear [ Name:%EMAIL_BODY Pattern Matching:Off ] 
A10: Variable Clear [ Name:%EMAIL_ATTACH Pattern Matching:Off ] 
A11: Variable Clear [ Name:%EMAIL_TO Pattern Matching:Off ] 

Adam Qualmann

unread,
Jun 2, 2013, 9:52:45 PM6/2/13
to tas...@googlegroups.com

That is exactlynwhat mine looks like, exactly, have spent the last three days working it, looking for extra spacing, spelling, anything that could be wrong.

But is the senemailA.py ok if it is in the script as a long run on code, or is it supposed to be set up on seprit lines with tabing and spacing? I had to copy past the code and that is what it did when I pasted. I keep reading on threads that you are supposed to download it but I don't see an actual download file or script.

--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/5b5PFQ2fqqs/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.

Adam Qualmann

unread,
Jun 2, 2013, 10:02:31 PM6/2/13
to tas...@googlegroups.com

I don't know if the pic will show up or not but its a screen shot of the code after pasting it into the sl4 script creater. And the file shows up in the list of scripts.

When I run the tasker it runs and I get notification at top of screen that sl4 is running the sendemailA.py script. I'm just not getting anything sent or receved.

On Jun 2, 2013 8:40 PM, "Mike L" <kitpri...@gmail.com> wrote:
Screenshot_2013-06-02-15-07-43.png

Mike L

unread,
Jun 2, 2013, 10:02:54 PM6/2/13
to tas...@googlegroups.com
I just copy/pasted the code here into Notepad ++ and saved is as sendemailA.py

You do have SL4A, and Python installed, right?

Mike L

unread,
Jun 2, 2013, 10:04:35 PM6/2/13
to tas...@googlegroups.com
In your screenshot you spelled the file name wrong

Adam Qualmann

unread,
Jun 2, 2013, 10:12:23 PM6/2/13
to tas...@googlegroups.com

Yes python and sl4 is installed. Fallowed the instuctions on that, the link you posted for the script takes me to the script that I copy/pasted. But it won't past in the same format. No spacing were the lines are supposed to end and everything is one long line when I turn wraping off.

Mike L

unread,
Jun 2, 2013, 10:22:42 PM6/2/13
to tas...@googlegroups.com
Are you doing this from your phone? I think it would be easier to do this from a computer. Copy the script into a text editor, save as sendemailA.py, and then put it on your phone in /sdcard/SL4A/Scripts

Adam Qualmann

unread,
Jun 2, 2013, 10:48:25 PM6/2/13
to tas...@googlegroups.com
On Sunday, June 2, 2013 9:22:42 PM UTC-5, Mike L wrote:
> Are you doing this from your phone? I think it would be easier to do this from a computer. Copy the script into a text editor, save as sendemailA.py, and then put it on your phone in /sdcard/SL4A/Scripts

I am on my tab 2 7.0. On the 4g LTE I will try doing Iit on the computer and moving Iit over. Am I going to be able to do that with out rooting the tablet? I will try. Be back to update after kids go to bed.
Thank you for the help

Adam Qualmann

unread,
Jun 2, 2013, 11:38:24 PM6/2/13
to tas...@googlegroups.com

I had two files saved, one spelled wrong one right,  checked and they bot had same content.

Adam Qualmann

unread,
Jun 3, 2013, 1:08:22 AM6/3/13
to tas...@googlegroups.com
On Sunday, June 2, 2013 9:22:42 PM UTC-5, Mike L wrote:
> Are you doing this from your phone? I think it would be easier to do this from a computer. Copy the script into a text editor, save as sendemailA.py, and then put it on your phone in /sdcard/SL4A/Scripts

Idea......
Seing as how I just realysed that the only computer we have is junk... won't open the web page were the script is,

Could someone email me the file in the right formate so I can just put it in the sl4a script location.

Or is there an andriod ap that will allow this to keep its structure when pasting.

At this point I know I could just pay for an app that does what this will and probably more. But this has gotten to be a battle and I must win...

Adam Qualmann

unread,
Jun 3, 2013, 2:28:28 AM6/3/13
to tas...@googlegroups.com

I was looking at the code after it pasted into sl4a. I noticed that because it did not hold its structure (one long run on code now) there are no spaces between some of the code.

Code looks like this after I past it into any text edit application. You will notice that there is no space for "import mimetypes for email" when the "types for email" is supposed to be on the next line....

import os import glob import mimetypes from email import encoders from email.mime.audio import MIMEAudio from email.mime.base import MIMEBase from email.mime.image import MIMEImage from email.mime.

I hope this makes moe sense,  having problems explaining, but that is the first part of the code I pasted from the clipboard on my tablet.

I was able to save it in .pdf format. So I printed it and am going to take the time to fix it using the papper as a guide.  This should work...... in theory. 

If there is a better way of doing this with out having to manualy fix this code please let me know. Not looking forword to the this,

Thanks
Adam

On Jun 3, 2013 12:55 AM, "joe" <morri...@gmail.com> wrote:
Hey Adam,  Sorry but I never realized that I posed in the 'with attachments' thread.  I never needed to send attachments.  I'm not really sure what part you're getting stuck at.  Here is my wiki entry on how to create automatic email sending.


Once you get that, I assume you'll need to code the program in your profile to attach a file.  Sorry I don't really know how to do that part, though. Good luck!

On Sunday, June 2, 2013 2:37:22 AM UTC-4, Adam Qualmann wrote:
On Tuesday, January 8, 2013 3:43:09 PM UTC-6, joe wrote:
> How is it that after 2 years the instructions on the wiki are still horrible?
>
>
> it says "include the parameters?  What parameters? The variable names or the variable values?  How should we put them in there?  Should we use commas? Do we fill in the variables with our own values? Should we be editing the script.   How about one simple example? I would be happy to change the wiki if I even knew how we should be putting these parameters into tasker, then maybe people won't waste an hour of their time like I have so far.

1 hour? I got 2 days on this and still stuck. And yes after 3 years you would think there would be, or at least a youtube vid. (When i get it working i might just do that)




James Morris

unread,
Jun 3, 2013, 12:03:07 PM6/3/13
to tas...@googlegroups.com
Adam,

This part is *much* easier than you're making it. Don't paste *ANYTHING*.   You should be downloading the scripts from the web, to a computer (not your phone).  Then use a good editor.  Notepad++ should work if you have to make modifications to the code. Save it. and then upload that file to the phone using a usb cable, samba server app, file sharing app, a file locker online.  Anything really.  But don't copy/paste code.  Generally I would tell you that whitespace doesn't matter, but i forgot python uses tabs for code blocks.  So this *may* be your problem.  Have you tried going into IRC for help?  There's a #tasker channel, granted there usually aren't many people in there.

Adam Qualmann

unread,
Jun 3, 2013, 12:09:25 PM6/3/13
to tas...@googlegroups.com

Ok, that makes a lot of sense, I will find a computer that will work, (not my moms) looks like I'm gonna get to dust off my baby. (Asus desktop with lots of upgrades)

Thank you so much for the help,
After I get it working I am thinking about making a dumb dumb video for it and posting it to youtube. Well, maybe when I learn a lil more about python and sl4.

Message has been deleted
Message has been deleted

Flippy12

unread,
Aug 28, 2013, 11:59:28 AM8/28/13
to tas...@googlegroups.com
If it can help someone in the future:

I had the popup "Email failed" when I was using this task.
I checked each of my parameter/variable, and all seems good, I didn't undersand why I had this error until I played with the parameter %EMAIL_BODY.
When I had the error, value of this variable was:                      Coordonnée GPS: %LOC & coordonnées GSM: %LOCN & batterie: %BATT
Now, I solved the problem by replacing the value with:           Location is %LOC (defined by %Loc_mode) & batterie level is %BATT

=> It seems that the character ":" is to avoid in the message body ;-)

(Now, I will solve my problem of file not attached)

Usman Farhat

unread,
Aug 29, 2013, 6:01:53 AM8/29/13
to tas...@googlegroups.com
Thanks, it worked perfectly!
But can you edit this script to add a notification "Email sent" when the email has been sent? Background is that I want to use this to send a random photo from my folder to my facebook page's email address, and then delete the image when it is sent. But the sending process takes time depending on size of image. I have added two minutes wait before messing with the file, but I want to do it in a different way:
I want that I will enable a profile (which will listen to event Notification) right after sending script, so when email is sent and it notifies me, the profile will be activated and it will delete the image followed by disabling itself, as I won't need the profile anymore.
I have no knowledge in python.

Michael Tepfer

unread,
Oct 21, 2013, 5:53:51 PM10/21/13
to tas...@googlegroups.com
Hi,

I am trying to make a simple app to record audio, then when the user presses a button, it sends it to a preset email.

I was able to get it to record the audio, but when I tried to send the email, it didn't work.

I am completely new to this, so I am probably missing something obvious.

Can you please help me out?

The attached XML contains my project with my username and password removed.

Thank you,
Michael
VN.prj.xml

Ryan Wilson

unread,
Dec 5, 2013, 7:07:33 PM12/5/13
to tas...@googlegroups.com
Could you help me with this?

Michael Tepfer

unread,
Dec 5, 2013, 7:28:11 PM12/5/13
to tasker
I ended up abandoning this script and I went with a paid plugin called 'Email Me Pro'.


On Thu, Dec 5, 2013 at 7:07 PM, Ryan Wilson <ryan...@gmail.com> wrote:
Could you help me with this?
--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.

To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.

Bob Hansen

unread,
Dec 5, 2013, 7:34:58 PM12/5/13
to tas...@googlegroups.com
I use Locale SendSilentMail Plug-In. It integrates with Tasker and has worked perfectly for me.

Adam Qualmann

unread,
Dec 12, 2013, 11:16:54 AM12/12/13
to tas...@googlegroups.com

I gave up on the scrip and got an app called gotcha pro. MUCH easyer to set up but don't have ths bragging rights

Stephen Allen

unread,
Dec 15, 2013, 6:15:36 PM12/15/13
to tas...@googlegroups.com


On Monday, October 25, 2010 3:28:39 PM UTC+1, baudi wrote:
I've written an SL4A Python script that lets you send an email with
attachments without going through the compose prompt.

Details here: http://tasker.wikidot.com/sl4a

This is just what I'm looking for - I have a Tasker script to monitor a folder for new files, however I have a nOOb question.

How do I pass the file name (of the file which triggers my email action) to the %EMAIL_ATTACH variable?

Kind regards,

Steve

Matt R

unread,
Dec 15, 2013, 8:28:50 PM12/15/13
to tas...@googlegroups.com
Variable Set action?

Matt

It is loading more messages.
0 new messages