robocorp / rpaframework

Collection of open-source libraries and tools for Robotic Process Automation (RPA), designed to be used with both Robot Framework and Python
https://www.rpaframework.org/
Apache License 2.0
1.17k stars 225 forks source link

`RPA.Outlook.Application` update/fix `Move Emails` keyword #1127

Closed mikahanninen closed 1 year ago

mikahanninen commented 1 year ago

Parameter email_filter's type has been changed so that it can be given

  1. a string email filter (existing functionality)
  2. single email (of type MailItem or dictionary representing email)
  3. list of MailItems/dictionaries.

Also added parameter mark_as_read which when set True will mark all emails which has been moved as Read (default).

usage example after this PR has been released

*** Tasks ***
All and filter
    Open Application
    ${emails}=    Get Emails
    @{move_these}=    Create List
    FOR    ${email}    IN    @{emails}
        Log To Console    SUBJECT: ${email}[Subject]
        IF    "Azure" in "${email}[Subject]"
            Log To Console    ... TO BE MOVED
            Append to List    ${move_these}    ${email}
        END
    END
    Log To Console    ... Moving ${{len($move_these)}} emails
    # Pass list of email dictionaries to move
    Move Emails    email_filter=${move_these}    target_folder=Azure    mark_as_read=True
    Log    Done.

Filter and move
    Open Application
    ${emails}=    Get Emails    email_filter=[Subject]='Azure AD Identity Protection Weekly Digest'
    IF    len($emails) > 0
         # Pass list of email dictionaries to move
        Move Emails    email_filter=${emails}    target_folder=Azure
    END

Move with filter
    Open Application
    # Pass email filter string (existing functionality)
    Move Emails    email_filter=[Subject]='Azure AD Identity Protection Weekly Digest'    target_folder=Azure