You can put the subroutine in any module, including ThisOutlookSession, but if you move the subroutine to another module or change the subroutine's name, you must modify the rule to point to the updated subroutine. MsgBox "Meeting request arrived: " & Item.Subject Sub CustomMeetingRequestRule(Item As Outlook.MeetingItem) MsgBox "Mail message arrived: " & Item.Subject
Outlook how to set a rule how to#
The following Outlook Visual Basic for Applications code illustrates how to create the subroutines: Sub CustomMailMessageRule(Item As Outlook.MailItem) A rule is an action that Microsoft Office Outlook takes automatically on an arriving or sent message that meets the conditions that you specify in the rule For example you can set a Rule to automatically move emails from a particular email address out of the Inbox to another folder. You cannot create one subroutine to handle both types of items by defining the argument to be of type Object. The argument must by of type MailItem or MeetingItem, otherwise the subroutine will not be available in the Rules Wizard. The name of the subroutine does not matter, but it must accept one argument because the Rules Wizard will pass a mail message (MailItem) or meeting request (MeetingItem) to the subroutine. To implement the custom code to process the message, create a subroutine in Visual Basic for Applications. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services.įor more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site: Microsoft Support Then choose the rules file you intend to import. From the list of options, select 'Import rules.'. Click on the options in the 'Manage rules and alert' window. Then select the 'Manage Rules and Alerts' window when you open Outlook. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. First, click on the 'File' tab at the left of the navigation ribbon. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. For additional information about limitations related to distributing Visual Basic for Applications projects, click the following article numbers to view the articles in the Microsoft Knowledge Base:Ģ90779 Description of managing and distributing Outlook 2002 Visual Basic for Applications (VBA) projects You cannot create the custom code in an Outlook COM Add-in.
Outlook how to set a rule manual#
Also, Outlook Visual Basic for Applications is not designed to be deployed, so deployment of this custom code requires manual configuration on each user's computer. Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.Although the Rules Wizard refers to the custom code as "script," you must create the code in Outlook Visual Basic for Applications, not in Microsoft Visual Basic Scripting Edition (VBScript) or other scripting languages such as Microsoft JScript. If you have extra questions about this answer, please click "Comment". If the answer is helpful, please click "Accept Answer" and kindly upvote it. īy "be applied to multiple user mailboxes", do you mean for these users, they each have a "Backup" folder in their own mailbox for Inbox backing up? If this is the case, I am afraid this is not feasible as there's no option availabe from either the Outlook desktop client side or the Exchange server side to prevent a user from managing his/her own mailbox folder. Next, Next, be sure to tick the checkbox of Run this rule now on messages already in "Inbox", Finish, so that the existing mails in Inbox folder will immediately be copied to the Backup folder.Īlso can we make the "Backup" folder read only to avoid deleting the emails ? and this has to be applied for multiple user mailboxes. Select the "Inbox" folder, click Home on the ribbon, Rules > Manage Rules & Alerts > New Rule.Ĭhoose "Apply rule on messages I receive", Next, Next:Ĭhoose "Move a copy to the specified folder", select the folder "Backup"(You can click "New" to create the target folder as needed): Hi you advise how to create a rule to copy (Not Move) all emails received to "Inbox" folder to another folder in outlook (Ex: Backup).