Scheduling an email with the Gmail API - gmail

I found a similar question from 2016, however at that time Gmail itself did not support scheduled sending of emails.
Now that you can schedule messages to send later directly from Gmail, I was wondering if there was a way to do it with their API.
Interestingly, scheduled emails appear as message objects when calling messages.list, but they do not contain any labels.
Any help would be appreciated! And if it's not possible at the moment, it would be awesome to get a reply from someone at Google about when this will become possible (I believe they officially endorse the gmail-api tag to StackOverflow)

I don't think a time-based trigger will work--even if you write the code to store email send data and then build something that regularly checks whether it's time for an email to be sent. See Google's documentation on triggers, and you'll notice that time-based triggers aren't available for Gmail scripts.

Unfortunately, there is no Gmail API endpoint for scheduling the sending of emails directly.
One workaround would be to write a script in Google Apps Script (https://script.google.com) which handles the composing of the email you wish to send, as well as a function to send the mail via the API. You can then use the built-in 'Apps Script Project Triggers' feature to trigger the function to run on a schedule; for example on action/event or at a specific/repeated time.
Button for adding trigger to Apps Script

Related

Is there any way to check if the emails sent by my app are open?

Hello I have developed an application that works with React.js and Node.js.
I use AWS and SES (Simple Email Service) to send some emails.
My question is whether there is any way I can keep track of emails sent and opened by my users to prevent them from qualifying me as spam or that my SES account health will decrease too much.
I have seen that there are some browser extensions with which it marks the emails sent with a double tick if the user have read it, but I do not have a record such as in gmail.
Has anyone encountered any similar problems?
Is it possible via AWS or via Node to achieve this?
Greetings and thanks in advance.
I agree with #Ravi's answer above - SES does provide notifications - however in my experience the open notification is a lot less reliable than the delivered and bounce notifications.
Tracking opens is difficult as browsers, popup blockers/security software and email clients themselves can disable/break features like read-receipts and tracking pixels in the name or privacy. The most reliable way of tracking opens is to have a clickable link in the email body (and a compelling reason for your user to click on it) and include a unique id in the URL that you can capture server-side.
With the help of some simple configurations with SES and SNS. By creating a topic and doing the subscription like where you want to get the notifications. Through this, you can track the status of your emails whether they are opened or not. SNS will send you email notifications.

How to check Gmail API usage status in Google Console?

I'm sending automated emails from my account to my account, I'm using Integromat (now Make) and I've done all the necessary stuff in the Google Cloud Platform (or Console) to authorize Integromat. The scenario works and I send automated emails.
However when I go to check the usage status to see how many emails I have sent and how many I have left in the Google console, it shows no results.
For reference, I go here https://console.cloud.google.com/apis/api/gmail.googleapis.com/ to check the status, but all the graphs show no data whatsoever, despite the automated mails getting sent normally. I have the correct project selected when doing this.
There is no way to see stats on any of your google usage quotas. The Stats page on Google cloud console. Is at best an estimate and not real time in any sense of the word.
Either create your own counter, or just wait until you get the quota error. I normally go with the latter.

trigger a .sh script when a specific subject email is received

Anyway, I have a script that I want to run whenever I receive an email on gmail. And if possible a subject specific email. is such a thing possible and if so, what programs do I need to allow it.
You can't instruct gmail to trigger an external script for you. I think you've got a few basic choices. In order of increasing difficulty and complexity:
1) Configure a gmail filter to deliver your desired messages to a special folder. Write a script to poll that folder, download (or delete or mark as read) messages it finds there, and then launch your local script. Set up a cron on your local machine to run the script every few minutes. You can poll the folder with IMAP or the GMAIL API. IMAP is probably easier. This will be tricky with shell, you're better of with Python, PHP, or similar.
2) Configure a gmail filter to forward your desired messages to an address on a mail server that you control. Use procmail or similar to intercept the incoming messages and launch your script.
3) Set up an account at Mailgun and configure the emails so they get delivered there directly. (Or forward from gmail as in #2.) Configure Mailgun to launch an API request when it receives messages. Build an API handler to receive the request. Launch your process from your API handler.
I have never done it, but I guess the first thing you should do is to take a look at the Google's Gmail API...
What is the Gmail API?
The Gmail API gives you flexible, RESTful access to the user's inbox,
with a natural interface to Threads, Messages, Labels, Drafts, and
History.
It seems to fit what you want - at least, without knowing the details of what you want to do.
The Gmail API can be used in a variety of different applications,
including, typically:
Read-only mail extraction, indexing, and backup
Label management
(add/remove labels)
Automated or programmatic message sending
You can use several programming languages - maybe the trick is using your programming language of choice to write a wrapper for the .sh script... I hope this helps!

Trigger event from gmail new mail

Is there an API or events that can be trapped within gmail so that I can initiate a workflow or even fire a python script.
I am trying to automate a job which will extract a csv attachment from an email that has arrived in gmail. It will then ETL the csv into BigQuery.
Any thoughts ?
Recently did this integration:
Turn on watching for message events: https://developers.google.com/gmail/api/v1/reference/users/watch
When you get a new incoming messageId (messagesAdded history type) you ask for its information (in full format): https://developers.google.com/gmail/api/v1/reference/users/messages/get
In metadata you look for a payload.parts[i] where it has body.attachmentId and get an attachment using its id: https://developers.google.com/gmail/api/v1/reference/users/messages/attachments/get
Im not sure within gmail itself,
but one thing you try is to write a python script utilising IMAP lib to read gmail messages and load it to bigquery using googleclient python. Set it using cron to run every x minutes to check the gmail account.
This should give you a starter code to read gmail messages:
https://gist.github.com/baali/2633554
If you want just new messages, just replace the search param 'ALL' with 'UNSEEN'.
More info:
https://docs.python.org/2/library/imaplib.html
Example python to load it to BigQuery:
https://developers.google.com/bigquery/loading-data-into-bigquery
I am still waiting for IFTTT https://ifttt.com/wtf to provide the API for users to create their own channel or custom action. i.e. Google BigQuery channel.
Hope that helps.

Gmail and Salesforce- long delay in forwarding email

We use Salesforce and Google Apps.
We have a Google Apps Email account that accepts an email and forwards this on to Salesforce, where Salesforce creates a case.
The last 2 fridays, we have had problems where it can take over 3 overs for an email to make its way into Salesforce.
How do I find out if the problem is with Google Mail not forwarding the email on in a timely manner, or the problem is Salesforce not processing it in a timely manner?
Anyone else ever had this problem?
Thanks!
A few ideas, which you may have already tried:
1) You could check the timestamps in Gmail to see when the emails were received and then forwarded to Salesforce to see if there was a delay.
2) You could check the dates against the Salesforce system status page to see if there were any reported issues: http://trust.salesforce.com/trust/status/
3) Same for the Google Apps status page: http://www.google.com/appsstatus
4) Check to see if there were any other delays in Salesforce or concurrent batch jobs that might have caused the delay.
5) Submit a support request to Salesforce to inquire.
Hmmm. Are you using Salesforce Email to Case? Here's someone posting a similar question: https://success.salesforce.com/questionDetail?qId=a1X30000000IGwWEAW. It seems that at the time that both problems were a temporary outage on the part of Salesforce. Also, are you using any apps to integrate Gmail and Salesforce? Because apps like The Scoop Composer allow you to forward emails and create cases right away. http://www.cloudgizmos.com/salesforce-gmail-integration. Hope this helps!

Resources