Friday, August 2, 2013

[Tasker] Take pictures of intruders and send them per mail silently

This script will detect when someone enters the wrong unlock code or swipes the wrong pattern and sends a picture to an E-Mail address in the background, silently.
For some reason it works better with long patterns and even better with long pin codes. I don't know why. If you know it, let me know :)

Let's start, please get:
  • Tasker
  • Secure Settings (To setup a profile in Tasker which detects wrong unlock codes)
  • Python for Android (To run python code)
  • SL4A (To run the python script from Tasker)
  • The python script "SendEmailA.py" from the Tasker Wiki. (Send an E-Mails silently)
  • GoogleMail address
Open the Python for Android application, make sure it is not Python3. Press install button to install the Python runtime environment.
Open SL4A and run the "hello_world.py" script by tapping on it and selecting the leftmost terminal icon. Congratulations, you successfully installed Python and can run Python scripts from Tasker!

Here is my "SendEmailA.py" script. It has a small modification to the original file which is marked in red.
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(email_name, email_user, email_pswd, mailto, subject, body, attachments):
  import smtplib

  # DON'T CHANGE THIS!
  # ...unless you're rewriting this script for your own SMTP server!
  smtp_server = 'smtp.gmail.com'
  smtp_port = 587

  # Build an SMTP compatible message
  msg = MIMEMultipart()
  msg['Subject'] = subject
  msg['To'] = mailto
  msg['From'] = email_name + " <" + email_user + ">"
  msg.attach(MIMEText(body, 'plain'))
  attach_files(msg, attachments)

  # 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( smtp_port == 465):
      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(smtp_port == 587):
      smtpObj.starttls()
      smtpObj.ehlo
    # Login, send and close the connection.
    smtpObj.login(email_user, email_pswd)
    smtpObj.sendmail(email_user, mailto, 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:
  email_name = droid.getIntent().result[u'extras'][u'%EMAIL_NAME']
except:
  email_name = ''
  
try:
  email_user = droid.getIntent().result[u'extras'][u'%EMAIL_USER']
except:
  droid.makeToast('EMAIL_USER missing')
  sys.exit(1)
  
try:
  email_pswd = droid.getIntent().result[u'extras'][u'%mailp']
except:
  droid.makeToast('EMAIL_PSWD missing')
  sys.exit(1)
  
try:
  mailto = droid.getIntent().result[u'extras'][u'%EMAIL_TO']
except:
  droid.makeToast('EMAIL_TO missing')
  sys.exit(1)
  
try:
  subject = droid.getIntent().result[u'extras'][u'%EMAIL_SUBJECT']
except:
  subject = ''
  
try:
  body = droid.getIntent().result[u'extras'][u'%EMAIL_BODY']
except:
  body = ''
  
try:
  attachments = droid.getIntent().result[u'extras'][u'%EMAIL_ATTACH']
  attachments = attachments.split(',')
except:
  attachments = ''

# Send email 
if (sendemail(email_name, email_user, email_pswd, mailto, subject, body, attachments)):
  sys.exit(0)
else:
  # Exit with error if email is not sent successfully
  droid.makeToast('email failed')
  sys.exit(1)


Save this file to your internal SDCard in the SL4A scripts folder (f.e. SDCard\SL4A\Scripts).

The preparation is done, lets go to Tasker. Create a new profile name it "Security Glitch" or something less obvious. Goto State -> Plugin -> Secure Settings. Click on the Edit field near configuration and select the condition "Failed Login Attempts". Type in a low number, like two. Enable "Device Admin". Read and accept the dialog. Click on save in the lower left corner. Hit the back button and create a new Task, name it "Cheeeese" or similar.
Here is my Cheeeese task:
Cheeeeese (45)
 Stay Awake
 A1: Vibrate [ Time:200 ]
 A2: Mobile Data [ Set:On ]
 A3: WiFi [ Set:On ]
 A4: Variable Add [ Name:%PHOTONUMBER Value:1 Wrap Around:0 ]
 A5: Take Photo [ Camera:Front Filename:%PHOTONUMBER Naming Sequence:None Insert In Gallery:Off Discreet:On Resolution:320x240 Scene Mode:Auto White Balance:Auto Flash Mode:Auto ]
 A6: Wait [ MS:0 Seconds:3 Minutes:0 Hours:0 Days:0 ]
 A7: Load Image [ Source:/sdcard/DCIM/Tasker/%PHOTONUMBER.jpg ]
 A8: Rotate Image [ Direction:Right Degrees:90 ]
 A9: Save Image [ File:/sdcard/DCIM/Tasker/%PHOTONUMBER.jpg Image Quality:70 Delete From Memory After:On ]
 A10: Wait [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ]
 A11: Variable Set [ Name:%EMAIL_USER To:mygooglename@gmail.com Do Maths:Off Append:Off ]
 A12: Variable Set [ Name:%EMAIL_P To:MyCleartextPassword Do Maths:Off Append:Off ]
 A13: Variable Convert [ Name:%EMAIL_P Function:Base64 Encode Store Result In:%EMAIL_P ]
 A13: Variable Convert [ Name:%EMAIL_P Function:Base64 Decode Store Result In:%mailp ]
 A14: Variable Set [ Name:%EMAIL_TO To:myemailtosendto@domain.com Do Maths:Off Append:Off ]
 A15: Variable Set [ Name:%EMAIL_ATTACH To:/sdcard/DCIM/Tasker/%PHOTONUMBER.jpg Do Maths:Off Append:Off ]
 A16: Run SL4A Script [ Name:SendEmailA.py Terminal:Off Pass Variables:%EMAIL_USER,%mailp,%EMAIL_TO,%EMAIL_ATTACH Continue Task After Error:On ]
 A17: Vibrate [ Time:616 ]

And here you can see the profile as an xml to directly import into Tasker, save it as SecurityGlitch.prf.xml.
<TaskerData sr="" dvi="1" tv="4.1u3m">
<Profile sr="prof44" ve="2">
<cdate>1353285745747</cdate>
<edate>1376868760042</edate>
<flags>1</flags>
<id>44</id>
<mid0>45</mid0>
<nme>Security Glitch</nme>
<pri>10</pri>
<State sr="con0">
<code>11820</code>
<Bundle sr="arg0">
<Vals sr="val">
<com.intangibleobject.securesettings.plugin.extra.BLURB>Failed Login Attempts - Max: 2</com.intangibleobject.securesettings.plugin.extra.BLURB>
<com.intangibleobject.securesettings.plugin.extra.BLURB-type>java.lang.String</com.intangibleobject.securesettings.plugin.extra.BLURB-type>
<com.intangibleobject.securesettings.plugin.extra.MAX_LOGIN_FAILURES>2</com.intangibleobject.securesettings.plugin.extra.MAX_LOGIN_FAILURES>
<com.intangibleobject.securesettings.plugin.extra.MAX_LOGIN_FAILURES-type>java.lang.Integer</com.intangibleobject.securesettings.plugin.extra.MAX_LOGIN_FAILURES-type>
<com.intangibleobject.securesettings.plugin.extra.SETTING>max_failed_pass_attempts</com.intangibleobject.securesettings.plugin.extra.SETTING>
<com.intangibleobject.securesettings.plugin.extra.SETTING-type>java.lang.String</com.intangibleobject.securesettings.plugin.extra.SETTING-type>
<com.twofortyfouram.locale.intent.extra.BLURB>Failed Login Attempts - Max: 2</com.twofortyfouram.locale.intent.extra.BLURB>
<com.twofortyfouram.locale.intent.extra.BLURB-type>java.lang.String</com.twofortyfouram.locale.intent.extra.BLURB-type>
<net.dinglisch.android.tasker.subbundled>true</net.dinglisch.android.tasker.subbundled>
<net.dinglisch.android.tasker.subbundled-type>java.lang.Boolean</net.dinglisch.android.tasker.subbundled-type>
</Vals>
</Bundle>
<Str sr="arg1" ve="3">com.intangibleobject.securesettings.plugin</Str>
<Str sr="arg2" ve="3">Secure Settings</Str>
</State>
</Profile>
<Task sr="task45">
<cdate>1353285761891</cdate>
<edate>1375520404009</edate>
<id>45</id>
<nme>Cheeeeese</nme>
<pri>10</pri>
<stayawake>true</stayawake>
<Action sr="act0" ve="3">
<code>61</code>
<on>false</on>
<Int sr="arg0" val="200"/>
</Action>
<Action sr="act1" ve="3">
<code>433</code>
<Int sr="arg0" val="1"/>
</Action>
<Action sr="act10" ve="3">
<code>547</code>
<Str sr="arg0" ve="3">%EMAIL_USER</Str>
<Str sr="arg1" ve="3">yourlogin@gmail.com</Str>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
</Action>
<Action sr="act11" ve="3">
<code>596</code>
<Str sr="arg0" ve="3">%EMAIL_P</Str>
<Int sr="arg1" val="25"/>
<Str sr="arg2" ve="3">%email_p</Str>
</Action>
<Action sr="act12" ve="3">
<code>547</code>
<Str sr="arg0" ve="3">%EMAIL_TO</Str>
<Str sr="arg1" ve="3">receivermail@domain.com</Str>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
</Action>
<Action sr="act13" ve="3">
<code>547</code>
<Str sr="arg0" ve="3">%EMAIL_ATTACH</Str>
<Str sr="arg1" ve="3">/sdcard/DCIM/Tasker/%PHOTONUMBER.jpg</Str>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
</Action>
<Action sr="act14" ve="3">
<code>112</code>
<se>false</se>
<Str sr="arg0" ve="3">sendemailA.py</Str>
<Int sr="arg1" val="0"/>
<Str sr="arg2" ve="3">%EMAIL_USER,%email_p,%EMAIL_TO,%EMAIL_ATTACH</Str>
</Action>
<Action sr="act15" ve="3">
<code>61</code>
<on>false</on>
<Int sr="arg0" val="616"/>
</Action>
<Action sr="act2" ve="3">
<code>425</code>
<Int sr="arg0" val="1"/>
</Action>
<Action sr="act3" ve="3">
<code>888</code>
<Str sr="arg0" ve="3">%PHOTONUMBER</Str>
<Int sr="arg1" val="1"/>
<Int sr="arg2" val="0"/>
</Action>
<Action sr="act4" ve="3">
<code>101</code>
<Int sr="arg0" val="1"/>
<Str sr="arg1" ve="3">%PHOTONUMBER</Str>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
<Int sr="arg4" val="1"/>
<Str sr="arg5" ve="3">320x240</Str>
<Int sr="arg6" val="0"/>
<Int sr="arg7" val="0"/>
<Int sr="arg8" val="0"/>
</Action>
<Action sr="act5" ve="3">
<code>30</code>
<Int sr="arg0" val="0"/>
<Int sr="arg1" val="3"/>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
<Int sr="arg4" val="0"/>
</Action>
<Action sr="act6" ve="3">
<code>188</code>
<Img sr="arg0" ve="2">
<var>/sdcard/DCIM/Tasker/%PHOTONUMBER.jpg</var>
</Img>
</Action>
<Action sr="act7" ve="3">
<code>191</code>
<Int sr="arg0" val="1"/>
<Int sr="arg1" val="1"/>
</Action>
<Action sr="act8" ve="3">
<code>187</code>
<Str sr="arg0" ve="3">/sdcard/DCIM/Tasker/%PHOTONUMBER.jpg</Str>
<Int sr="arg1" val="70"/>
<Int sr="arg2" val="1"/>
</Action>
<Action sr="act9" ve="3">
<code>30</code>
<Int sr="arg0" val="0"/>
<Int sr="arg1" val="2"/>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
<Int sr="arg4" val="0"/>
</Action>
<Img sr="icn" ve="2">
<nme>yummy_6</nme>
<pkg>net.dinglisch.android.ipack.iconedenthemeshd</pkg>
</Img>
</Task>
</TaskerData>


Please make sure the folder "/sdcard/DCIM/Tasker/" exists and you have the right information filled in in the purple fields. You can put a file named .nomedia into the DCIM/Tasker/ folder to make sure, it is not displayed in the gallery.
If you don't know how to setup a specific action, please google it. Line A16 is very important. To create this line goto Script -> RunSL4A Script -> in the name field select the "SendEmailA.py" file. Don't check the Terminal field, but fill in the Pass Variable field with %EMAIL_USER,%mailp,%EMAIL_TO,%EMAIL_ATTACH. The order is important. Check continue task after error.

You can delete the bright blue lines after running the Task once successfully. Please note, that your Google Mail password is stored as a global variable in Tasker Base64 encoded - but it is not a safe encryption! If you have suggestions on how to store the password encrypted n Tasker, please tell me!

Run the task a few time to check if your device vibrates twice (short vibrate at the beginning and a long vibrate at the end. Check your myemailtosendto@domain.com mails, don't forget to look into the spam folder. If you received a picture exit Tasker, lock your device, count to ten and check by entering the wrong unlock code/pattern a few time. Maybe you can make the profile run with a higher priority, not necessary. If everything went well and you received the beautiful pictures of yourself delete the bright blue lines.
Uninformatively there is an android limitation which will show the SL4A icon for a second in the notification bar when the email is send... I tried to make python run without SL4A, but was not successful yet. A workaround could be to make the icon transparent...

I wrote this down pretty fast, please forgive me if something is unclear. I will refresh this post soon.

56 comments:

  1. Replies
    1. You're welcome!
      btw fixed a small error in the python script ^^" Forget to escape the <> characters when posting here...

      Delete
    2. This comment has been removed by the author.

      Delete
  2. Could you please supply your XML? The load image doesn't work for me. I don't know how to load an image with a variable name.

    ReplyDelete
    Replies
    1. I'm having the same difficulty. I'm receiving an email but there are no attachments. It looks like the image is being taken and saving in the appropriate directory.

      Delete
    2. I've created a pastebin with the Tasker task in xml format that I was able to get to work. I also have the SecureSettings GPS on enabled.

      http://pastebin.com/m5SxRQbn

      Delete
    3. Unfortunately, it doesn't look like it works with triggering from Secure Settings failed login attempts.

      I'm running an S3 with CleanRom 7

      Delete
    4. And here my XML, delete the write LOG line..

      http://pastebin.com/xWdxAnFX

      Working on Samsung Galaxy S3 with Android 4.1.2

      Delete
    5. I love this, and I'm almost there with it fully working, I just can't for the life of me get it to actually send me the picture. I can see the picture that was taken in the expected directory place, and the emails sends, there is just no attachment. I've checked, re checked and double rechecked, and seem to have everything right, but no attachment. Where could I be going wrong? Also, I wish to try directly importing the links you guys have posted on pastebin to the XML files, but how to I actually import those to Tasker?

      Delete
  3. Thanks for your time and effort with this, but I too find that it hangs my phone and wants to kill Tasker. It eventually reboots my phone and never got to the SL4A script. (Never saw the icon that it was running as I have seen while trying to set this up using a different source). That source and this one never took a picture.(I have it storing in gallery until I can make sure it is working). It also removed the task from Tasker, causing me to have to re-input it again.

    ReplyDelete
    Replies
    1. I have since started re-inputting this code and testing it along he way. It seems the task of taking a photo is rebooting my phone. Apparently I can't use this, but again, thanks for your work.

      Delete
    2. That's a pity :( What phone and android version do you use?

      Delete
  4. Thanks for that manual, it works great with My HTC One, however, if I use face lock + pattern it doesn't work. any suggestions? is there another command I need to add?

    ReplyDelete
    Replies
    1. You could try the application and Tasker plugin "Security Settings" (root), it can unlock your phone, do the desired stuff and then lock it again...

      Delete
  5. I'm having a problem where the process won't start till the phone is unlocked, Do you know how to fix this?

    ReplyDelete
    Replies
    1. Has Tasker all privileges?
      If yes.. then:
      You could try the application and Tasker plugin "Security Settings" (root), it can unlock your phone, do the desired stuff and then lock it again...

      Delete
  6. Hi, i think there is a possibility for CyanogenMod users to prohibit the SL4A-Icon; in the Apps-Menu you can block single apps from showing notifications. Unfortunately I cant test it because my phone does not have a frontcamera, but maybe someone else can?

    ReplyDelete
    Replies
    1. One could try to look into the apk and replace the icon by a transparent one..

      Delete
    2. I have it disabled through Gravitybox Ongoing Notification blocker.

      Delete
  7. error 3 : base64 encoded string is not 4 characters...

    or something like that. It doesn't stay on the screen for long! Pictures being taken though! Galaxy S3 on PA 3.98 :)

    ReplyDelete
    Replies
    1. you have problems with the password being encoded and decoded... hmm strange.. have you written all the variables the correct way? make some debugging by placing some "show messages dialogs" in between the lines.

      Delete
  8. So, my password will be available in tasker?

    ReplyDelete
    Replies
    1. For the one who knows where to look - definitely yes. You just "hide" it, you don't protect it :(

      Delete
  9. Hi, thanks for your effort and time

    I'm having a problem .. It all ways tell me that "email failed", IDK what is the problem I checked every step again and again and everything is ok !

    ReplyDelete
    Replies
    1. Make some debugging, try the task to send emails with the password being hardcoded and not passed in the variable. Still not working? It only works with gmail

      Delete
    2. what do you mean by password hardcoded

      Delete
  10. Thanks man, thus works great but you have an error that gave me a little problem, you put A13 twice! Haha, also this works by failing the patter with long lines, not short ones

    ReplyDelete
  11. Great work, thank you! :) Worked perfectly for me!
    I have a little question: Is there a simple way to get also the gps location?
    Thanks in advance

    ReplyDelete
  12. Hi.
    what am I suppose to write in the purple field at step a12 and a14? (I have a swipe pattern lock)

    When i test this task inside tasker with the "play" funktion, it snaps a photo and saves it to "/sdcard/DCIM/Tasker/"..but no email was sent to my gmail..

    and when I enter the wrong swipe pattern to test it out it doesn't do anything..no photo´s nothing..

    does anyone have an idea what went wrong?

    ReplyDelete
  13. I really appreciate this task & all of the effort therein.

    Unfortunately, even when porting the XML in directly, I get an error message: "EMAIL_PSWD missing" on rooted LGG2 stock 4.2.2

    I have quadruple-checked the steps (and then some) and got the same error message when I input each step line-by-line; in fact, I have found a discrepancy: in the text above, line 13 (the second, darker one with the "decode" action) stores the result in %mailp, but in the ported XML the direction stores the result in %email_p (both are referenced properly in Line 16).

    I've tried changing all the "%EMAIL_P" variables to "%EMAIL_PSWD" and making sure that they are all referenced in line 16, but I have had zero success.

    Have you any suggestions?

    ReplyDelete
    Replies
    1. To be clear, my password is entered properly in Line 12.

      Delete
  14. I have also tried setting the "%EMAIL_P=%EMAIL_PSWD" and "%EMAIL_PSWD=%EMAIL_P" variables, but these haven't worked, either.

    ReplyDelete
  15. Got it figured out:

    I set a new variable %EMAIL_PSWD as [my password] and followed all the steps for the %EMAIL_P variable - in the end I was able to delete everything referencing "%EMAIL_P" .... I still had trouble when I deleted the encode command (blue line 13) so I just left it in; subsequent tests were successful.

    Thanks again for all of your work, Benny!!

    ReplyDelete
  16. This is a fantastic website, could you be interested in going through an interview concerning just how you made it? You can visit my site. Exit intent technology






    ReplyDelete
  17. also receivng an error about EMAIL_PSWD missing. Followed each step, triple checked all entries, but although photo is taken, it is only stored in the /path mentioned above. No emails are sent.

    ReplyDelete
    Replies
    1. Did you try what worked for me: setting %EMAIL_PSWD as I described above on March 1?

      Delete
  18. Replies
    1. I had to clear out all the Python & SL4A and to a fresh install of them at one point. Also I've noticed that for some reason, if I tried to right click the "SendEmailA.py" script that had been edited by Benny and save it as it was through Windows it would save as an empty file; doing a copy/paste into notepad & saving the traditional way solved this.

      Also I got a little confused with the instruction and eventually replaced all of the %mailp & %emailp variables with %EMAIL_PSWD - I mean all of them. At this moment it's working for me, but there are absolutely no references to either of those variables - both the variable convert direction results are stored in %EMAIL_PSWD (which might be why it won't run for me with the first Line 13 deleted, but I've made my peace with that).

      It's possible that this has made my password less secure; I got around this by simply opening up an entirely separate Gmail account solely for this purpose that sends the email to a specific address on my mail server also created solely for this purpose. Both are edited, cleaned & maintained through Outlook, so it's not the logistical nightmare it may sound like. It also helped with the troubleshooting, since I was able to confirm whether the email had been sent without being received. I don't know why, but I also had to edit Line 11 to remove the @gmail.com part before it would work.

      Also I had to recreate line 16 after downloading the new SendEmailA.py script. My pass variables are %EMAIL_USER,%EMAIL_PSWD,%EMAIL_TO,%EMAIL_ATTACH (also don't forget the commas, I made that mistake & it took me twenty minutes to find it) and I just used the search function to find it instead of typing the name.

      Delete
    2. To be honestly i cannot figure this out. can you post your xml and such?

      Delete
    3. Never mind I figured it out.

      Delete
  19. I just ported the xml from here & changed the gmail settings to reflect my own. Glad to hear that you got it all worked out! What did it turn out to be that was getting in your way?

    ReplyDelete
  20. yeah right. Well I did it both ways, by copying all the text to Tasker manually, and also "your" way, and changed the gmail settings and I still get errors even with the added variable convert setting you added in a previous post, so I did what was necessary.....I flushed the profile and looking elsewhere for something that works!

    ReplyDelete
  21. How do I import the xml file and use it in tasker?

    ReplyDelete
    Replies
    1. In Windows all you have to do is copy all the text into a new Notepad file & click File => Save As (make sure "all files" is enabled in the drop-down.

      Delete
  22. Hi! Attachment not working. Please Help!
    I want to run 'sendemailA.py' from SL4A to send a mail with attachment.
    I am hard-coding the varible 'attachment' value with a picture's file path present in my sdcard as bellow but I receive the email without the attachment.
    The attachment line I have changed in 'sendemailA.py' is as follows:
    ...
    body = droid.getIntent().result[u'extras'][u'%EMAIL_BODY']
    except:
    body = ''

    try:
    attachments = '/sdcard/pictures/myphoto.jpg'
    # commenting it droid.getIntent().result[u'extras'][u'%EMAIL_ATTACH']
    # attachments = attachments.split(',')
    except:
    attachments = ''

    # Send email
    if (sendemail(email_name, email_user, email_pswd, mailto, subject, body, attachments)):
    ...

    ReplyDelete
  23. I created actions EXACTLY THE WAY IT IS DIRECTED ABOVE, but on testing the task it shows an error toast "EMAIL_PSWD MISSING"
    Kindly help what to do to correct it?

    ReplyDelete
    Replies
    1. I ended up defining a new variable. It eventually worked & I ended up getting rid of a couple of previously defined variables. I think the March 19th post should cover it.

      Delete
  24. Please lemme know the Exact work around for this error... Thank u!

    ReplyDelete
  25. Im able to perform all tasks perfectly, except, attaching the photo in email. I receive Blank email. Kindly help.

    ReplyDelete
    Replies
    1. Did you remember to set a different variable to attach the picture to the email? It's line A15 above, though there is an error in the list.

      Delete
  26. Can Someone post a working xml and script

    ReplyDelete
  27. the problem i have is every time i try to run this I get unfortunately, SL4A has stopped

    ReplyDelete
    Replies
    1. This happened to me, too. It turns out that whenever I did anything regarding the operating system (including adjusting the ROM through Titanium Backup) I had to reinstall Python & SL4A

      Delete
    2. so just the python and SLA4 apps not the script?

      Delete
  28. ok just found locale send silent mail. works great no hair pulling and its a tasker plugin
    https://play.google.com/store/apps/details?id=com.stedo.sendsilentmail&hl=en

    ReplyDelete