Support > Forums > OpenBots Studio > Get IMAP Emails

Get IMAP Emails

Alberto Zamora

  • Reporter
  • Calender Icon August 22,2022 at 4:48 AM

Hello OpenBots community

I am trying to access Gmail messages with the "Get IMAP Emails" command, I already configured as requested, and also created the password in a variable in "New SecureString", also in my gmail account, activate the option of " IMAP" but when executing the RPA it throws an error message "Invalid credentials", I use version 1.8.1 of OpenBots Studio. Can you help me please.

Thanks.

This forum has 314 topics, 681 replies, and was last updated 17 days ago by Support Agent

Nataly Alvarado...

  • Participant
  • Calender Icon August 24,2022 at 7:33 PM

Hi alberto-15-30,

Do you get any specific error when running your script? ​ Please follow the below steps: ​

  1. Set your Client Secret value using New Secure String command or retrieving value from OB Credentials Vault

  2. Use the Get IMAP Emails command to extract targeted emails. To filter emails accordingly, make sure to include the following: ​

    • Folder name (in caps for gmail INBOX).
    • Filter - when filtering by subject, you only need to indicate the subject name
    • Unread Only - when set to YES bot will only extract emails if they are in unread state
  3. Use the For Each command to loop through the extracted list of emails. Make sure Output Collection Item variable type is set to MimeMessage

  4. Use the Get Mime Message Attachments command to get and save the attachments related to each mime message

When you run your process your list should be populated with the extracted emails information. See reference below:

Alberto Zamora

  • Participant
  • Calender Icon August 23,2022 at 9:48 PM

Hello OpenBots team.

I have reviewed the information provided and it helps me a lot, I can now access the email with the "GET IMAP EMAILS" command, now I have one more question, I try to download attachments from multiple emails, through a list of subjects that come from an Excel range and using a "for each" also with the "IMAP" commands, but I still can't do it, I don't know where the error is, I think it could be in the filter to be able to search the emails. Could you help me with an example, or point me where I can find one.

Thanks for the help. Greetings.

Nataly Alvarado...

  • Participant
  • Calender Icon August 22,2022 at 5:09 PM

Hi alberto-15-30,

To access your Gmail account through SMTP/IMAP commands, please follow the steps detailed in Google's documentation to enable account. Setup the corresponding host and port information, also included in the link: https://support.google.com/mail/answer/7126229?hl=en

Please note that Gmail has added new security requirements to access imap through 3rd party applications. Including enabling OAuth2 login: https://community.spiceworks.com/topic/2458266-o365-imap-not-working-3rd-party-apps-sites-issue-as-of-july-21-2022

This option is supported by setting the OAuth2 Authentication Type in the IMAP/SMTP commands to GMAIL. You can follow the steps detailed in this guide to generate the resquested Client ID and Client Secret: https://github.com/jstedfast/MailKit/blob/master/GMailOAuth2.md

You are not authorized to reply, please click here to login and add your reply to this topic.