Link to home
Start Free TrialLog in
Avatar of E=mc2
E=mc2Flag for Canada

asked on

Simple script to see any new emails in Office365

Is there a Powershell or VBS or batch script that can be run which will show you quickly similar to an inbox, for Office365 emails, perhaps specifycing
simply any new emails received in an Inbox with From, Subject and Time.. like a quick view?

I wanted to be able to run a script from a menu, perhaps called 1.Email, and then quickly log into Office365 email to see if any new emails have come in etc.. without having to open Outlook or any other major email client..
Avatar of Alex
Alex
Flag of United Kingdom of Great Britain and Northern Ireland image

I have one question, why? I mean you even get a popup with outlook.

Don't bother trying to reinvent the wheel, it'll be longer for you to run the script than it would be if you just opened up outlook and left it open.
Yes, you can. You use EWS (Exchange Web Services)

After connecting
# Get the Mailbox ID of the Inbox folder.
$inboxFolderID = [Microsoft.Exchange.WebServices.Data.FolderId]::new([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox,$MailAddress)

# Bind to the inbox folder.
$boundFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($objExchange,$inboxFolderID)
$boundFolder.UnreadCount

Open in new window

https://stackoverflow.com/questions/44160461/checking-number-of-unread-exchange-mails-with-ews
Avatar of E=mc2

ASKER

Thanks Shaun.  And what would be the script to connect then? Or what is before this??
It is the first part on that link, the section in OP's question
Avatar of E=mc2

ASKER

Thanks again Shaun.  Ok, I added credentials etc., however now I don't know where to replace the script you provided or what to remove in order to make it work?
Avatar of E=mc2

ASKER

This does not work, I found another solution online.
ASKER CERTIFIED SOLUTION
Avatar of E=mc2
E=mc2
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial