How to get unread mails from unread mail folder from outlook

I’m getting an error while trying to get unread mails from “unread mail” folder in outlook . Error says “The specified folder doesn’t exists”. Please help me with this…

@Shree_Vybhavi Download Following File

Hi thank you for your quick response. But i want to read UNREAD MAILS from UNREAD MAIL FOLDER of outlook is there any solution for that !!! If i use “UNREAD MAIL” as a folder name in property field it says error as “The specified folder name doesn’t exists”.

Hi Shree,

Please find the below powershell script to get unread mails of Inbox folder from Output.

$OL=New-Object -ComObject OUTLOOK.APPLICATION
$ns =$OL.GETNAMESPACE(“MAPI”)
[string]$Folder =“Inbox”
$mail = $ns.Folders.Item(1).Folders.Item($Folder).Items.Restrict(’[UnRead] = True’)
$Mail_Htmlcontent=$mail | Select-Object -Property Body
$Mail_Htmlcontent
$FilePath=“C:\Users\lb\Desktop\ExchangeTest\EmailOutput.txt”
New-Item $FilePath
forEach ($Each_Tag in $Mail_Htmlcontent)
{
Add-Content $FilePath $Each_Tag
}

this script will write unread emails body into text file.

Please change the file path to your system path.

Use this script and you can run power shell script using Uipath.

I hope this can be helpful.

Thanks
Latika