Link to home
Start Free TrialLog in
Avatar of K B
K BFlag for United States of America

asked on

Rest API: Move all users Deleted Items content to their Sent Items (Exchange Online)

I am not a .net developer but work with PowerShell a bit.

Is this a process that is even possible and if so how do i get it done?

Thank you
Avatar of Adam Brown
Adam Brown
Flag of United States of America image

An inbox rule should be able to do this. Not sure how to handle it programatically, but you can create an Inbox rule that will move all Deleted items to any other folder. Not sure on Powershell syntax, but the new-inboxrule cmdlet will let you create a rule for this.
Avatar of K B

ASKER

If I am not mistaken inbox rules are rules that run on Messages that hit the inbox based on conditions set forth in the rule. I'm not sure how you would affect change on any other folder.
Yes, it's possible. "All" you need to do is build a search for items in sent items and use the Move method to push them to a new folder. You can use whatever language you prefer to work with the REST API of course. I'd use PowerShell, but I like PowerShell best.
ASKER CERTIFIED SOLUTION
Avatar of Vasil Michev (MVP)
Vasil Michev (MVP)
Flag of Bulgaria 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
Avatar of K B

ASKER

I need to build these rules server side for 150 users to move all the items that are currently sitting in their Deleted Items to their Sent Items... I was unaware that new-inboxrule could do this..

Frankly it would be best if I could identify if they have a RetentionPolicyTag applied to them and only move those.
Avatar of K B

ASKER

am I missing something

Use the New-InboxRule cmdlet to create Inbox rules in mailbox mailboxes. Inbox rules process messages in the Inbox based on conditions specified and take actions such as moving a message to a specified folder or deleting a message.
SOLUTION
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
Avatar of K B

ASKER

exactly, yet now I am curious if inbox rules can affect change on anything but the inbox...

anyway, can this be done with PowerShell?  Any idea on how to get started?
I've cnever found a way to remotely execute a rule. Granted my perspective lacked Exchange admin access so I'm quite prepared to be corrected.

The rest interface can be used to enumerate and move messages. Unless you know of another way I suggest you stick with that.
SOLUTION
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
Avatar of K B

ASKER

I am curious how an inbox rule can work in this scenario.. is there a document for it?
Avatar of alohadin
alohadin

I have actually written a Powershell script that utilizes the REST api to Scan the mailbox for all mails containing attachments with certain extensions, if found it will download those attachments to a location and move the mails to a subfolder.

It's for a special mailbox... don't ask.
But it can be edited to only move mails.

The REST API is not very difficult to understand once you get the hang of it.
It even works with App Passwords if MFA is enabled.
Avatar of K B

ASKER

Can someone confirm that rules will not work for this?