Search code examples
emailpowershelloutlookautomationscheduled-tasks

Logging into Outlook using powershell with no user logged on


I was wondering if its possible to create a powershell script to log into a specific outlook mail box and than add the script to the scheduled task so that no user has to be logged on.


Solution

  • If you need to open an arbitrary Exchange mailbox, you can either

    1. Use Outlook Object Model (which cannot be used in a service, such as the Scheduler) to log to a predefined profile (Namespace.Logon) and call Namespace.GetSharedDefaultFolder. If the set of mailboxes is always the same, you can add these static mailboxes to the profile (open them as delegate mailboxes) and access them programmatically using the Namespace.Stores collection. Again, Outlook should not be used in a service/scheduler.

    2. Exchange Web Services - it is HTTP based, so you can use it from a service

    3. Graph - just like EWS, it is HTTP based, so you can use it from a service

    4. Extended MAPI (C++ or Delphi only). native API used by Outlook itself. It can be used in a service.

    5. Redemption (I am its author - it wraps Extended MAPI and can be used in any language from a service). It lets you dynamically log to an Exchange mailbox using RDOSession.LogonExchangeMailbox / LogonExchangeHostedMailbox (no existing profile required). Other mailboxes can be opened using RDOSession.GetSharedMailbox.