Sign In Try it free

Listing Emails


Email model

See mailbox model in the reference.

Listing emails

Without providing any additional parameters, the email list endpoint will return the latest [TBC] emails across all email accounts.

Example

token = "<user's token>"
client = LivilApi::Service.new(token)
"bu"bku
emails = client.list_emails

emails
# => [LivilApi::Email(id: '...', subject: 're: An important message', ...), ...]

Meta

Pagination and count information is available in the meta hash.

NOTE:
The total_results from some providers are estimates, so this number should not be treated 100% accurate.

Example
          emails = client.list_emails

emails.meta
# => <OpenStruct next_page="abcd23kjasdkfjlasdjf", total_results=34>

Applying filters

There are a number of filters which may be applied to the request in order to limit the returned results.

NOTE:
Unless othewise specified below, all filtering and searching is performed by the provider APIs. Contents are not scanned by the WorkAPI system.

Standard Parameters

The email list endpoint supports the following standard parameters:

Mailbox

The mailbox_id refers to the WorkAPI mailbox ID.

Any emails that appear in a mailbox with one of the specified mailbox_ids will be included in the result set (subject to pagination).

Emails may have multiple mailboxes so multiple IDs may be present.

NOTE:
In Gmail, an email which has been both sent and received by the same account will contains IDs for both the Inbox and Sent mailboxes.

Example
        emails = client.list_emails(mailbox_ids: ['ABCDE...']) 

emails
# => [LivilApi::Email(id: '...', ..., mailboxes: [LivilApi::Mailbox(id: 'ABCDE...')])]

Date range

The date range filters by the `received_at` date and time. Any emails that were received between those dates will be included in the result set (subject to pagination).

Example
          emails = client.list_emails(date_from: '2019-10-01T00:00z', date_until: '2019-12-31T00:00z') 

emails
# => [LivilApi::Email(id: '...', ..., received_at: '2019-11-01T10:30z')]

Contact

Specific contact information can be matched against emails in your account by passing a contact object.

Example
          contact = LivilApi::Contact.new(first_name: 'Dave', last_name: 'Smith')
contact.email_addresses << LivilApi::ContactEmailAddress.new(address: 'dave.smith@livil.co')
emails = client.list_emails(contact: contact) 

emails
# => [LivilApi::Email(id: '...', ..., sender: 'Dave Smith ')]
Example
emails = client.list_emails(search_text: 'your subscription') 

emails
# => [LivilApi::Email(id: '...', body: [LivilApi::EmailBody(plain_text: '... renew your subscription today...')])]

First 50,000 requests are free every month