App Inventor Extensions


Mail Extension

See the App Inventor Extensions document about how to use an App Inventor Extension.

For questions about this extension, bug reports and feature requests, please start a new thread in the App Inventor Extensions forum. Thank you.

July 10th, 2016: Version 1 of the Mail Extension released (POP3 blocks are still experimental!)

Aug 11th, 2016: Version 1a: avoid DX execution failed error: build each extension separately

Dec 30th, 2016: Version 1b: simplification in send method, which fixes SSL issue, Base64Decode method added

Feb 14th, 2017: Version 1c: added permission android.permission.ACCESS_NETWORK_STATE to be able to send attachments via mobile internet

Description

This extension enables you to send an email via SMTP. You can send to several To, Cc or Bcc addresses, add several attachments and send in plain text or HTML format. Note: SMTP authentication is set to true.

To use this extension together with Gmail accounts, you have to enable less secure apps in the Google settings, see also Why do I get AuthenticationFailedException when accessing Gmail?.

Required permissions: android.permission.INTERNET, android.permission.READ_EXTERNAL_STORAGE, android.permission.WRITE_EXTERNAL_STORAGE, android.permission.ACCESS_NETWORK_STATE

Probably you want to read this first: What is SMTP?

This extension uses the Javamail API version 1.5.5. Thank you Oracle!

Note: There are also blocks available to receive emails via POP3, but these are still experimental... What is POP3?

Common

Properties


Returns username.


Specifies username.


Returns password.


Specifies password.

SMTP

Properties


Returns from (i.e. the email address of the sender of a message).


Specifies from (i.e. the email address of the sender of a message).


Returns SMTP host.


Specifies SMTP host. Default value is smtp.gmail.com.


Returns SMTP port.


Specifies SMTP port. Default value is 465.


Returns whether text should be sent in HTML format.


Specifies whether text should be sent in HTML format. Default value is false.

Methods


Send email.
Subject and To address are mandatory. For To, Cc and Bcc you can add several addresses, use a comma as delimiter. Also you can add several attachments, use a comma as delimiter. You can't send attachments from the assets of the app.

Events


Event indicating that email has been sent.
In case of success, the flag successful is true and the text "success" will be provided as response. In case of failure, the flag successful is false and an error message will be provided as response.

Example App: Mail Extension SMTP Test

Enter your settings and send emails to several To, Cc or Bcc addresses, add several attachments and send in plain text or HTML format to test the functionality of the Mail extension.

Screenshots:

SMTP - Questions and Answers

Q1: When I tried the .apk it gives as response javax.mail.AuthenticationFailedException 534-5.7.14?
A: To use this extension together with Gmail accounts, you have to enable less secure apps in the Google settings, see also Why do I get AuthenticationFailedException when accessing Gmail?.

Q2: Would you be able to assist me with the file location needed to send a different file in my test I am using ///storage/emulated/0/Folder/File.txt?
A: You can use a full path, which is file:///mnt/sdcard/Folder/File.txt or a relative path, which is /Folder/File.txt.

POP3

currently experimental...
There are also blocks available to receive emails via POP3, but these are still experimental...

Properties


Returns POP3 host.


Specifies POP3 host. Default value is pop.gmail.com.


Returns POP3 port.


Specifies POP3 port. Default value is 995.


Returns the max. number of messages to check or fetch.


Specifies the max. number of messages to check or fetch. Default value is 10.


Returns directory to save attachments after fetching emails.


Specifies directory to save attachments after fetching emails. Default value is AI.

Methods


Check emails.
Only the following information is downloaded for each email: number, from address, subject and sentDate.


Fetch emails.


Decode a base64 encoded string, which can be found in an email address. The string must start with =?UTF-8?B? and must end with ?=. Example: =?UTF-8?B?2KPYs9in2YXZhyDYs9mK2KfYsQ==?=


Decode a quoted-printable string, which can be found in an email address.
Example: =?utf-8?Q?Taifun_B=C3=A4r?= will be coverted to Taifun Bär.

Events


Event indicating the progress of the checking process.
As it takes a few seconds to download the information depending on the number of emails to check, you can follow the progress of the checking process here.


Event indicating that emails have been checked.
If Check was successful, the flag 'successful' is true, 'number' will be the number of available messages and the following information will be provided in the 'response' in JSON format for each message: number, from, subject, sentDate.


Event indicating the progress of the fetching process.
As it takes a few seconds to download the information depending on the number of emails to fetch, you can follow the progress of the fetching process here.


Event indicating that emails have been fetched.
If Fetch was successful, the flag 'successful' is true and the following information will be provided in the 'response' in JSON format for each message: from, to, cc, subject, sentDate, contentType, content, attachments. To keep it simple, only the first To and Cc address will be provided (in case there is one). You can set the directory for the attachments to be stored in the property 'SaveDirectory'.

Example App: Mail Extension POP3 Test

Enter your settings and check for available emails or fetch emails to test the functionality of the Mail extension.

Screenshots Check Mails


Screenshots Fetch Mails



A message including inline images

A message including an attachment

Note: Inline Images will be downloaded and stored in the folder defined in the SaveDirectory property, which is by default directory AI. The content of the email will be adjusted accordingly by the Mail extension to link to the inline images from that directory. The example app uses the webviewer to display the message. The HTML code will be passed in the Webviewstring property of the Webviewer.

Known Issues for POP3

  1. Testing for Gmail accounts worked fine. For other hosts (I tested gmx.de and strato.de) after fetching emails the already downloaded emails still appear as to be downloaded.
  2. There is an issue in the pop3.aia test app to fetch emails, which have non ASCII characters (for example Russian characters). Unfortunately I will not be able to fix this, because I do not have emails with Russian characters to test. Therefore you can use the POP3 part of the extension for ASCII characters only.

Do you need help with your App Inventor project?

I can help you: for one hour I charge 25 USD.
Please contact me at info [at] puravidaapps [dot] com for details!
For questions about App Inventor, please use the App Inventor forum. Thank you.

Test the functionality of the Mail extension

The SMTP test app is available in Google Play for Beta testers. You can test the example following these steps

  1. Join the Taifun Test Google+ Group to be able to test the example app
  2. Then follow the opt-in URL to get access to the app and to be able to download it to your device. It might take a few hours for Google to enable you as beta tester!
  3. Start testing.

Note: The POP3 blocks are still experimental!

Buy the Mail extension for App Inventor


You can buy this extension (aix file).
With your payment you accept the terms and conditions below.

Payment options

1. Paypal

Please transfer 10 USD via Paypal
to Pura Vida Apps

2. Bitcoin

After having received your payment I will be happy to send the extension (aix file) to you.
Thank you! Taifun


Please check your spam folder in case you did not receive the extension!
I usually will send the extension not later than 24 hours after having received your payment.

 

Terms and Conditions

Back to top of page ...


Home | Snippets | Tutorials | Extensions | News | Forums | Links | Search | Contact