I am attempting my first Logic App, which will trigger from an email. It will then look for any email addresses in the body of the email, and send an individual slack message to a channel with the email address as the text.
So far, all I can do is post one message to the channel with an array of the email addresses.
Here's what I am doing...
When an email arrives, first initialize an array :
Then I convert the email body to text (to remove any HTML)
Then I find any addresses in the above text :
Then I set the above emails variable with :
createArray(outputs('Find_Email_Address_in_Email')['body'])
And Finally I send a slack message in a loop based on the Emails array :
What gets posted to slack is :
(The whole array, when I want it to run once for each email in the list).
I think I am either setting the array incorrectly, or the for each isnt set up correctly?
I got it.
On the Set Variable section, Instead out using the output straight from the JS execution, I convert it to JSON first like :
json(outputs('Previous_Step_Name')['body'])
Related
I am looking for ways to slim my gmail account.
E.g. Is it possible to write a script that would do one of the following:
remove attachments from quoted text.
remove quoted text.
replace images in with links to high quality images on my G-drive.
perform an arbitrary text operation on previously received emai.
Note I don't want this to happen in the new email: I want do to this on whole folders (labels) of old mail. E.g. open the conversation thread from 2017 with the subject line, "Do you have swedish aspen" and replace each occurrence of 6 pix of SA with links?
You could use the API to get old messages, the thing is these messages if they contain attachments, or images, or whatever, they are base64encoded in your mail box.
Now what you are proposing is a kind of reconstruction of your mail box. A way to do something like that would be for example to:
Get all original messages using the Gmail API
Process them with your code
Use the insert method of Gmail API to insert the slimmed messages
Delete the originals using Gmail API
Note:
Using the insert message enables you to preserve the original dates of the messages.
References:
Users.messages: get
Users.messages: insert
Users.messages: delete
So basically what I am looking to do is grab a new item from a list every time i call that list. My list looks something like this
testemail+0#gmail.com
testemail+1#gmail.com
testemail+2#gmail.com
testemail+3#gmail.com
...
So I will automatically send the email to the first one and then send the keys for the body text after. I have all the open and close email window, I am just not sure how to pull the next email address I want when i start the next email.
My ideal goal for this project is to be able to store all the emails in a separate file and then take the emails from that file
so basically every time i query the variable it has the next item in the list
thanks in advance appreciate it
I am just not sure how to pull the next email address I want when i start the next email.
for email_address in open('emails.txt').read().splitlines():
send_email(email_address)
When using gmail API, history.list method we get "bare" message ids with no additional field from the fields in 'labelAdded', 'labelRemoved', 'messageAdded', 'messageRemoved'. Why is that? And is it possible that a new message has been added but when we use this method, the field messageAdded hasn't been used, so we receive it "bare" ?
According to the GMail history API, the list only contains the id and threadId fields.
It works this way because the objective of the history API is to provide you with the changes that happened in the mailbox, not its contents.
After you obtain the list from Users.history: list you need to call Users.messages: get or Users.messages: list to get the full messages.
If the messageAdded field is empty, it means that no new messages were added after the last historyId you examined. You might have skipped some. Make sure that every time you query the API you internally store the last historyId you processed so you can resume from that point in the future and not lose any changes.
In the history list endpoint is recommended to use specific change-type fields like messagesAdded rather than the messages field.
However I've noticed that when receiving an email with an attachment or without body (just the subject) the messagesAdded field is empty while the messages field has an entry.
Is this the correct behaviour? I was expecting the messagesAdded key with a value as well.
The get message API, Gmail API to fetch particular email, doesn't returns modified time of email. Modified time should change whenever someones reads an email.
Also there is a field called 'Date' which is return as part of 'payload.headers[].name'. What does this value indicates? From my testing it stores sent/received time of emails.
Use case: WebDav clients expects modified time for legal hold policies.
Reference: https://developers.google.com/gmail/api/v1/reference/users/messages/get
Snippet of message received from Gmail API:
{
"historyId":"8567",
"id":"14e87d4358bde1db",
"internalDate":"1436797907000",
"labelIds":["INBOX","IMPORTANT","CATEGORY_PERSONAL","UNREAD"],
The internalDate epoch timestamp is at least in Java available using message.getInternalDate method.
I am not 100% sure if this value is updated on reading the message, but I assume so since it updates the message labels by removing UNREAD label.