連接至 IMAP 電子郵件伺服器

連接至 IMAP 🡥 電子郵件伺服器。

指令可用性: IBM RPA SaaS 及 IBM RPA 內部部署

說明

連接至 IMAP 🡥 電子郵件伺服器,並將建立的連線儲存在變數中。 此指令會在電子郵件的 收件匣 資料夾中執行直接搜尋。 若要指定資料夾,請使用 Apply Search Filters (emailApplySearchFilters) 指令。

Script 語法

IBM RPA 的專有 Script 語言具有類似於其他程式設計語言的語法。 Script 語法在 Script 檔中定義指令的語法。 您可以在 IBM RPA Studio的 Script 模式中使用此語法。

imapConnect --mailhost(String) --mailport(Numeric) [--usessl(Boolean)] [--UseConnectionToSend(Boolean)] [--smtpcredentials(Boolean)] --smtphost(String) --smtpport(Numeric) --smtpusername(String) --smtppassword(String) [--smtpusessl(Boolean)] [--username(String)] --mailusername(String) [--mailpassword(String)] [--enableLog(Boolean)] (EmailConnection)=value

相依關係

  • 如果您使用 IntegrationConnection 鑑別類型,請參閱 連線

輸入參數

下表顯示此指令中可用的輸入參數清單。 在表格中,當您在 IBM RPA Studio的 Script 模式及其 Designer 模式對等標籤中工作時,可以看到參數名稱。

設計程式模式標籤 Script 模式名稱 必要 接受的變數類型 說明
IMAP 位址 mailhost Required Text 電子郵件伺服器的 IMAP 位址。
mailport Required Number 要連接之 IMAP 伺服器的 TCP 埠。
鑑別類型 authenticationtype Required Text 鑑別的類型。 請參閱 authenticationType 參數選項
連線 connection Required when the authentication type parameter is IntegrationConnection text 租戶中可用的連線。
使用 SSL usessl Optional Boolean 啟用時,它會針對 IMAP 使用安全通訊協定 SSL 🡥
傳送電子郵件 UseConnectionToSend Optional Boolean 啟用以容許連線也傳送電子郵件。
使用自訂的 SMTP 認證 smtpcredentials Optional Boolean 啟用後,將容許欄位使用自訂的 SMTP 🡥 電子郵件傳送通訊協定。
SMTP 位址 smtphost Required when the Use Customized SMTP Credentials parameter is enabled Text 電子郵件伺服器的 SMTP 位址。
SMTP 埠 smtpport Required when the Use Customized SMTP Credentials parameter is enabled Number 要連接之 SMTP 伺服器的 TCP 埠號。
SMTP 使用者名稱 smtpusername Required when the Use Customized SMTP Credentials parameter is enabled Text 在 SMTP 伺服器上註冊的用戶端使用者名稱。
SMTP 密碼 smtppassword Required when the Use Customized SMTP Credentials parameter is enabled Text 在 SMTP 伺服器上註冊的用戶端使用者密碼。
針對 SMTP 使用 SSL smtpusessl Optional Boolean 啟用後,將容許對 SMTP 使用 SSL 🡥 通訊協定。
使用者名稱 username Optional Text 用於電子郵件鑑別的使用者名稱。

🛈 請記住: 通常這是 IMAP 伺服器上所登錄帳戶的電子郵件位址。
電子郵件 mailusername Required Text 連線的電子郵件位址。
密碼 mailpassword Optional Text 用於連接的電子郵件的密碼。
要存取的共用信箱 sharedboxaddress Optional Text 您想要存取的共用信箱。
⚠ 注意: 如果您提供信箱,指令只會連接至此共用信箱,而不是連接至 電子郵件上設定的帳戶。
啟用記載功能 enableLog Optional Boolean 啟用通訊協定記載 (如果有的話)。

%localappdata%\IBM Robotic Process Automation 目錄會儲存日誌檔。

authenticationType 參數選項

下表顯示 authenticationType 輸入參數可用的選項。 此表格顯示在 Script 模式下以及在 Designer 模式對等標籤下工作時可用的選項。

設計程式模式標籤 Script 模式名稱 說明
BasicAuthentication basicAuthentication 使用基本鑑別來鑑別協力廠商帳戶。 需要使用者名稱和密碼。
IntegrationConnection integrationConnection 使用來自您登入之租戶的 Oauth 鑑別連線。

輸出參數

設計程式模式標籤 Script 模式名稱 接受的變數類型 說明
連線 value Email Connection 包含電子郵件的 收件匣 資料夾中所有訊息的集合。

範例

範例 1: 指令使用自訂的 SMTP 通訊協定連接至 IMAP 電子郵件伺服器,並啟用電子郵件傳送。

defVar --name emailDestination --type List --innertype String --value "[destination@email.com]"
defVar --name emailConnection --type EmailConnection
imapConnect --mailhost "outlook.office365.com" --mailport 993 --usessl--UseConnectionToSend--smtpcredentials--smtphost "smtp.office365.com" --smtpport 587 --smtpusername "useremail@email.com" --smtppassword userpassword --smtpusessl--username "useremail@email.com" --mailusername "useremail@email.com" --mailpassword userpassword --enableLogemailConnection=value
emailSend --connection ${emailConnection} --to ${emailDestination} --from "useremail@email.com" --subject test --bodytype "Text" --body "Message body"
// Sending an email over the IMAP connection with SMTP protocol.

範例 2: 連接至 IMAP 電子郵件伺服器,並在包含附件檔的所有資料夾上搜尋電子郵件。

defVar --name emailDestination --type List --innertype String --value "[destination@email.com]"
defVar --name emailConnection --type EmailConnection
defVar --name outputConnection --type EmailConnection
// Connect to IMAP Email server
imapConnect --mailhost "outlook.office365.com" --mailport 993 --mailusername "useremail@email.com" --mailpassword userpassword
// Apply a filter to search only for emails with attachments in all folders.
emailApplySearchFilters --searchallemails  --subjectdirective "All" --wordsdirective "All" --withattachment  --connection ${emailConnection}
// Disconnect from the server.
emailDisconnect --connection ${emailConnection}

🛈 記住: 上述範例僅供說明,因此若要讓它運作,您必須輸入有效的 IMAP 連線及其適當的設定。

限制

  • 您必須取得電子郵件提供者中的埠、使用者名稱及密碼資料。

  • 傳送電子郵件 參數可讓您使用 IMAP 連線來傳送電子郵件,不過,對於部分電子郵件伺服器,必須配置此傳送。 否則,執行 Script 時會發生錯誤。 如果無法配置此傳送,建議使用 使用自訂 SMTP 認證參數 及自訂 SMTP 通訊協定。

  • 若要傳送電子郵件,連線必須使用原始電子郵件帳戶,而不是別名。 使用別名電子郵件帳戶的連線只能讀取電子郵件。 暫行解決方法是將您的電子郵件提供者新增至 Microsoft™ Outlook 服務,並使用 連接至 Microsoft Outlook (outlookConnect) 指令。