Google Gmail Extension
Extension Name: Google Gmail
Description: A Non-Visible component that helps you to send mail from your App Inventor App using Google App Script.
Date Buit: 2022-01-18T18:30:00Z
Requirements: Google Account, App Script deployment key
Blocks
Error Occurred
Description: Event raised when the error occurred from network connectivity.
Params: errorMessage(String message generated when the error occurred.)
Mail Send
Description: Event raised when code execution completed from Google App Script, if mail not sent then also this event raised with appropriate status and message.
Params: status("ok" if mail sent successfully), message("mail sent successfully" if mail sent successfully else error message)
Send Mail
Description: Call App Script function to send message to given mailId with given subject and body.
Params: mailId(Email Address of the recipients), subject(Subject of the mail), body(Body text of the mail).
Deployment Key
Description: Set your App Script deployment key.
Google App Script
function doPost(request) {
let emailId = request.parameters.mail_Id;
let emailBody = request.parameters.body;
let emailSub = request.parameters.sub;
const output = {};
try {
GmailApp.sendEmail(emailId, emailSub, emailBody);
output['status'] = 'ok';
output['msg'] = 'mail sent successfully';
} catch (err) {
output['status'] = 'error';
output['msg'] = err;
}
return ContentService.createTextOutput(JSON.stringify(output)).setMimeType(ContentService.MimeType.JSON);
}
Notes
- At the deployment time it may ask you to grant permission to access the data related to Gmail.
- Don't share your deployment key with others(Even me also).
- Deployment Configurations (Execute as: Me (Your Mail Id), Who has access: Anyone)
Download Link
com.google.preet.aix (10.8 KB)
Happy App Inventing
Preet P. Vadaliya