$rule = $rules.create("My rule1: Receiving Notification", $namespace.GetDefaultFolder(::olFolderInbox) With the namespace in hand, we specify the originating folder (the Inbox), create a new rule and specify the folder to copy to (Notifications). $namespace = $Outlook.GetNameSpace("MAPI") $Outlook = New-Object -comobject Outlook.Application This code gives us access to the messaging namespace of the Outlook API, in which typical objects are e-mail messages, Outlook rules and mail folders, among other objects (for more information, see ). The first piece of business is to invoke the Outlook API using code such as the following. One rule reads a message’s subject line for the specific string “Notification” and then copies relevant messages to a specified folder (named Notifications). This section takes a stab at demonstrating programmatic creation of two Outlook rules. What we need is a quick, automated method to assign values to e-mails in both your Inbox and Sent Items such that a PowerShell script can be run to allocate them to the correct folders. The subject line might cover one or two of the criteria and be susceptible to formal manipulation by an Outlook rule, but that often places too much trust in any given sender's subject lines. While Steve Masters's e-mail can easily be copied to a related folder, the other relevant factors in his message-that it concerns finance, Dubai and Project X, among other possible criteria-are much more difficult to translate into actions. What’s more difficult to do, and generally outside the capacity of Outlook rules, is to get a single e-mail into multiple folders based on more amorphous criteria than standard rules contemplate. And that goes for other standard rules operations. For example, copying messages from Steve Masters to a related folder in Outlook is a relatively straightforward matter. The rules facility in Outlook is often useful in addressing these kinds of situations, and code I’ll present in this article shows how to automate the creation of rules. (And if you receive a large volume of email, it’s all the more vital to automate some of the management tasks involved.) And all without you having to manually click around the Microsoft Outlook interface multiple times for each item of mail. It would be useful to have an automated way to distribute copies of this message to folders for Project X, Steve Masters and Dubai, and ultimately to yet another folder for safekeeping. Say an e-mail from Steve Masters comes in regarding the finances on Project X in Dubai. Have you ever needed to find an e-mail message from one or two years ago that, if you couldn’t find it, might adversely affect your circumstances? Does your company automatically delete messages from your Inbox or Sent Items folders? Do you get tired of copying e-mails to multiple folders when they touch on multiple topics of interest-a particular project, manager, subject matter, company division or the like? Volume 28 Number 03 PowerShell - Managing an Outlook Mailbox with PowerShell
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |