Outlook Get Emails
Outlook Get Emails
Section titled “Outlook Get Emails”Type: outlook-get-emails · Package: Outlook Activities v1.0.4 · Output: List<ZoanMail>
Reads the emails of an Outlook folder and returns a list of messages (ZoanMail). It is the starting point of almost every mail-based process: read what arrived, loop over it and act on each message.
How it works
Section titled “How it works”- Resolves the
folder(default Inbox). It accepts English aliases (inbox,sent,drafts,deleted,junk,outbox), the name Outlook shows in your language and paths with/— see Folders. - Sorts the items from newest to oldest (by received date).
- Applies the filter: if you set
filter, that one is used; otherwise, withunreadOnly = true, only unread items are taken. - Returns up to
maxCountemails. Meeting requests, read receipts and other items that are not emails are skipped and do not count towards the maximum.
Reading does not change the emails: they stay unread until you use Outlook Mark Read. Without session, the default account is used.
Required parameters
Section titled “Required parameters”None.
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanOutlookSession | — | Session from Outlook Connect. Inherited inside the Connect body; without a session the default account is used. |
folder | string | "Inbox" | Folder to read. Alias, localized name or path with / for subfolders: "Inbox/Customers". |
maxCount | int | 50 | Maximum number of emails to return. A value that is not a whole number is treated as 50. |
unreadOnly | bool | false | Return only unread emails. Ignored when you set filter (add it to the filter instead: [UnRead] = True). |
filter | string | — | Outlook filter applied to the folder items. Outlook syntax ("[Subject] = 'Invoice'", "[UnRead] = True AND [SenderEmailAddress] = 'vendor@company.com'") or DASL with the @SQL= prefix for content searches. |
Output
Section titled “Output”Returns a List<ZoanMail> sorted from newest to oldest. Each email has .Id (EntryID), .Subject, .From, .To, .Cc, .Body (plain text), .SentAt (received date) and .IsRead; .Attachments and .Bcc are empty. Details in What each email contains.
If no email matches, it returns an empty list (not an error): check it with count(emails) == 0.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
Folder not found at level {0} of the path (under {1}). {2} | A segment of folder does not exist. The message gives the level and how many subfolders there are; check the spelling or use the name Outlook shows. |
Outlook did not return its default folder. Check that Outlook is installed, has a configured mail profile, and runs at the same elevation level as the robot (…) | There is no usable mail profile, or the robot and Outlook run at different elevation levels. Configure the profile and run both at the same level. |
COM component 'Outlook.Application' is not registered. Is the application installed? | Outlook is not installed on the robot’s machine. |
| Outlook error when parsing the condition | filter has invalid syntax (quotes, property name). Test the filter with a fixed value before building it with expressions. |
Example
Section titled “Example”Read the unread emails of the inbox, save their attachments and mark them as read:
Outlook Get Emails folder = "Inbox" unreadOnly = true maxCount = 20 → output: emails
For Each items = emails itemVariable = email └─ activities: Log message = "From: " + email.From + " — " + email.Subject Outlook Get Attachments entryId = email.Id outputDir = "C:/invoices" → output: files Outlook Mark Read entryId = email.IdUseful filters (what you type in the filter field):
[Subject] = 'Invoice 1043' exact subject[UnRead] = True AND [SenderEmailAddress] = 'vendor@company.com'@SQL="urn:schemas:httpmail:subject" LIKE '%Invoice%' subject containing «Invoice»Related activities
Section titled “Related activities”- Outlook Get Attachments — save the attachments of an email.
- Outlook Reply / Outlook Move Email — act on an email.
- Data types › ZoanMail — properties of each email.