Google Gmail Extension

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

component_event(1)

Description: Event raised when the error occurred from network connectivity.
Params: errorMessage(String message generated when the error occurred.)

Mail Send

component_event(2)

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

component_method(1)

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

component_set_get(1)

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


  1. At the deployment time it may ask you to grant permission to access the data related to Gmail.
  2. Don't share your deployment key with others(Even me also).
  3. 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

14 Likes

good extension

it would be nice if you could add bcc, cc

please , tutorial desain n blok

It is all mentioned. Blocks are also provided.

Does the Google script cause a certain email limit or api request limit? I wont be 100% happy if the api limit is like 10 or 100 a month

1 Like

A personal gmail account can send up to 100 emails a day (last time I looked)

If you have a google workspace account then you are into the thousands

1 Like