Description
This activity allows you to read emails from a specified date. When you add this activity to the canvas, the "Save value to variable" activity is automatically added. This activity is optional and can be removed.
Third-party application access
For Studio Pro and your email client to work correctly, the option to allow third-party applications must be enabled in your email settings. You can learn more about this setting in this article (given Gmail as an example).
Read emails from folders and subfolders
With this activity, you can read emails from any folders and subfolders in your mail client. Typically, a mail client has a hierarchy of several folders, e.g:
- Inbox
- Inbox subfolder
- Sent
- Important
- Important subfolder
- Drafts
If you want to read mails from a certain folder, you have to specify its full name with a /
character, for example: Inbox/{{Subfolder name}}
Please note that in this case you must specify the original name of the folder. If in your mail client the inbox is called "Inbox", you must write that name of the parent folder. For example, if the "Inbox" folder contains the "Work" folder, you must write the path to the folder in the "Mail folder name" parameter like this: Inbox/Work
Note. Some mail services may use a different syntax for specifying folders.Gmail requires the following syntax for specifying the folder with sent emails: [Gmail]/Sent Mail
. Note that you can also specify other folders with that syntax: [Gmail]/Folder name
.
In case of other services, if a folder is not recognized when the parameter is filled like this: Inbox/Work
, try specifying the subfolder name only (Work
), or change the /
symbol to |
.
How to work with credentials
To start using this activity, you first need to enter your credentials.
The button to add new credentials.
This article describes in detail the process of adding credentials.
Parameters
Host and email
Click on the drop-down list to select the required host/login pair. Then start typing your host or login name so that this pair (email address) appears at the top of the list.
Server settings
This option allows you to specify the settings of the server used for e-mail messages.
- Custom: allows you to manually select the protocol "IMAP" or "POP3", enter the server address in the "Server address" field and select a secure connection.
- Secure connection - if this checkbox is checked, then the connection will be performed using TLS.
- Yandex: the default settings for the Yandex server are applied.
- Google: The default settings for the Google server are applied.
- Yahoo: The default settings for the Yahoo server are applied.
- Mail.ru: Mail.ru default settings are applied.
- iCloud: The default settings of the "iCloud" server are applied.
Date from
If there is no value for the “Date from” parameter, emails from the last 24 hours will be read.
- Set a value: allows you to explicitly specify the date from which the mail messages are to be read. If you click in the corresponding field, the calendar will pop up, in which you can manually select the desired date.
- Calculate a value: allows you to use a special formula or a special method to specify the date from which the messages are to be read.
- Save the previous step result: takes the result of the function from the previous workflow action as the date.
Filter by status
Unread only
Read the emails with the "Unread" status only.
Starred only
Read the emails marked as "Important" only.
From a specific category (Gmail)
Read the emails from the category you specified.
Filter by content
Subject contains
Retrieve emails with a specific subject.
- Set a value: allows you to manually write a keyword for the subject of an email.
- Calculate a value: allows you to use a special formula or a special method to specify a keyword.
- Save the previous step result: takes the result of the action from the previous workflow step as the keyword.
Body contains
Retrieve emails that contain a certain value in the body (text) of the email.
- Set a value: allows you to manually set a keyword for the body of the letter.
- Save the previous step result: takes the result of the action from the previous workflow step as the keyword.
- Calculate a value: allows you to use a special formula or a special method to specify a keyword.
Sender
Retrieve emails that came from a specific sender.
- Set a value: allows you to manually specify the sender of an email.
- Calculate a value: allows you to use a special formula or a special method to specify the sender.
- Save result of previous step: takes the name of the sender from the result of the previous step in the workflow.
Reading groups of emails
In some cases, certain email services (for example, Gmail) would group several emails. They will be displayed in a single line. Gmail would also show the number of emails by the name of the sender.
Pay attention to the fact that the bot will read all the emails following the specified filters, including all the emails from the group. Thus, if the bot would read the emails shown in the screenshot, the total number of emails would be six.
Attachments
- Reserved characters (
/
,?
,<
,>
,\
,:
,*
,|
,"
,.
and..
).
In the case they are used, Studio Pro will automatically remove them.
Download attachments
Allows you to download the attachments from all read emails for a specified period.
Save duplicate with new name
With this option it is possible to save several files with the same name in the same folder. Thus, the second and subsequent files will not overwrite the first one, but will be saved under a new name - the date in unix format will be added before the name of the file itself.
Directory path template
The option is available only if the Download attachments option is selected. It requires you to specify the folder where the files will be uploaded. It is also possible to specify {{keyword}}
in the path to save the attachments, where keyword
is one of the parameters listed below:
from
- sender;to
- the recipient;cc
- those specified in the copy;date
- date the message was sent;messageId
- unique identifier of the message;dateTime
- date time in ISO format;dateTimeMs
- date and time in unixTime format;receivedDateTime
- date and time of receiving the message in ISO format;receivedDateTimeMs
- date and time of sending in unixTime format.
When keywords are added, the bot will automatically create sub-folders with the date or subject of the corresponding message. You can specify several keywords.
- Set a value: allows you to explicitly specify the path to the folder, for example,
C:\ElectroNeek\
orC:\ElectroNeek\{{date}}\{{subject}}
. - Calculate a value: allows you to use a special formula or a special method to form a folder.
- Save the previous step result: takes the result of the function from the previous workflow action as a folder.
Mail folder name
If you want to read mails from a subfolder, the path must be specified with |
. For example, there is an "Inbox" folder with a subfolder called "Work". The path to the "Work" folder should be set in the following way: Inbox|Work
.
- Set a value: allows you to specify explicitly the path to the folder from which you want to read the mail messages.
- Calculate a value: allows you to use a special formula or a special method for specifying a folder name.
- Save the previous step result: takes the folder name from the result of the previous step in the workflow.
Folder|Subfolder
or Folder/Subfolder
.
Emails Limit
This parameter only takes non-negative integers and allows you to limit the number of emails your bot should process. For example, if the “Emails Limit” is equal to five, then your bot will read only the first five emails.
- Set a value: allows you to manually set the number of emails your bot should process.
- Calculate a value: allows you to use a special formula or a special method to specify the number of emails your bot should process.
- Save the previous step result: takes the result of the action from the previous workflow step as the number of emails your bot should process.
Download original
If you select this checkbox, all downloaded messages will have the new {{keyword}}
parameter — original
. The original
parameter contains a raw email body in the HTML format.
Mark as read
This field checkbox you to mark emails processed by your bot as read.
Move to folder
This option allows you to move the read emails to a certain folder in the mailbox.
- Set a value: allows you to manually set the name of the folder, where the emails will be moved.
- Calculate a value: allows you to use a special formula or a special method to specify the folder.
- Save the previous step result: takes the result of the action from the previous workflow step as the name of the folder.
Comment
This parameter allows you to create an annotation to the activity. The input text will be displayed above the activity name.
Result
By default, the read emails are stored in the variable email_messages
. This variable is an array of objects, where each object corresponds to one email. The object contains the following keys and values:
[
{
"from": [
{
"name": "sender's name",
"address": "sender's email address"
}
],
"date": "time when this email has been sent",
"receivedDate": "time when this email has been received",
"replyTo": [
{
"name": "name from the 'reply-to' section of this email",
"address": "email address from the 'reply-to' section of this email"
}
],
"to": [
{
"name": "receiver's name",
"address": "receiver's email address"
}
],
"subject": "this particular email's subject",
"text": "this email's text processed with an html-parser",
"textPlain": "this email's text returned by the server",
"hasAttachment": "Whether the email has an attachment or not",
"original": {
"body": "A raw email body, if you have selected the Download original checkbox"
}
"cc": [
{
"address": "email addresses of secondary recipients",
"name": "names of secondary recipients"
}
],
"bcc": [
{
"address": "email addresses of tertiary recipients",
"name": "names of tertiary recipients"
}
],
"attachments": [
{
"path": "path to the first attachment"
},
{
"path": "path to the second attachment"
}
],
}
]
bcc
value. Therefore, in those cases, the bcc
cannot be retrieved.How to use it?
Use the "Read emails" activity when the bot needs to read emails. You can configure the bot so that an incoming email becomes a trigger for a workflow.