Get IMAP Mail Messages Timed Out While Waiting For Mail Service To Connect

How to resolve when IMAP Mail Messages obtains - Timed out while waiting for Mail Service to connect?

This article provides the resolution for error "Get IMAP Mail Messages: Timed out while waiting for Mail Service to connect" which might be obtained when trying to fetch mails from a Gmail account.

For fetching emails from the Gmail account through the IMAP protocol, make sure below requirements are first met:


If still an error persists in UiPath, try fetching through the below PS script. This script will print the subject of first ten emails. Update the respective details in the PowerShell script

1.png

Follow the below procedure to get imapx.dll: You can download the imapx from Manage Packages in UiPath

  1. Install IMAPX

2.png

  1. After installation you will find the dll in the below location C:\Users\YourUsername\.nuget\packages\imapx\2.0.0.18\lib\net452

If the error "cannot be loaded because running scripts is disabled on this system" is obtained when fetching mails through the above PS script, talk to your admin or check Microsoft documentation to allow execution. Read Set Execution Policy .

If the issue is still not resolved, attach the results of execution of above PS script, Mail activity package version and the connection details and create a support ticket with UiPath Product Support.

1 Like

A post was split to a new topic: Powershell script with Get IMAP mail messages activity is giving "Timed out while waiting for Mail service to connect. "

I resolved this issue. Thanks.
Please refer to the PS script below.

//[Reflection.Assembly]::LoadFile(“YourDirectory\imapx.dll”)

$client = New-Object ImapX.ImapClient

$client.Behavior.MessageFetchMode = “Full”
$client.Host = “outlook.office365.com”
$client.Port = 993
$client.UseSsl = $true
$client.Connect()
$user = “email”
$password = “password”
$client.Login($user, $password)
$messages = $client.Folders.Inbox.Search(“ALL”, $client.Behavior.MessageFetchMode, 10)
foreach($m in $messages) {
$m.Subject
}