`
oywl2008
  • 浏览: 1051800 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Description of programming with Outlook rules

 
阅读更多
There is a variety of ways to implement or create solutions that handle incoming and outgoing e-mail. This article is a general overview of the options that are available.

Overview of Rules

<script type="text/javascript"></script> With the Outlook Rules Wizard, you can manage both incoming and outgoing e-mail messages by defining instructions that should be applied to certain e-mail messages in certain scenarios.

NOTE: In earlier versions of Microsoft Outlook, this type functionality is provided by the Inbox Assistant. Although Outlook provides the Rules Wizard instead of the Inbox Assistant, the functionality that was provided by the Inbox Assistant is still used to process rules on Microsoft Exchange Server public folders.

For additional information about how to use the Rules Wizard, click the article numbers below to view the articles in the Microsoft Knowledge Base:
196212  (http://support.microsoft.com/kb/196212/EN-US/ ) OL2000: How to Use the Rules Wizard in Outlook 2000
291608  (http://support.microsoft.com/kb/291608/EN-US/ ) OL2002: How to Use the Rules Wizard in Outlook
When you develop solutions, it is important to understand that rules can run on the server or the client. All the Exchange Server-based rules are run first, and then Outlook client-based rules are run. If you are using an Exchange server, the rules are stored both locally on the client and also on the server. A rule is run on the server if it is possible; otherwise, the rule will be handled by Outlook on the client. The main disadvantage of client-side rules is that they can only run when Outlook is running online. Rules that cannot be completed on the server are marked "Client-only" in the Rules Wizard.

The following examples of Outlook rules can be run on the server:
  • Automatically reply to a message.
  • Move a message to another folder in the same store.
  • Copy a message to another folder in the same store.
  • Exchange Server public folder rules using the Folder Assistant.
The following examples of Outlook rules are run on the client:
  • Move a message to a folder in a PST file
  • "Custom Action" rules
You can use the Rules Wizard, and you can also use various technologies to create solutions that implement rules functionality. Some of these technologies integrate directly with the built-in Exchange Server and Outlook rules functionality. Others use independent custom code to create a solution that functions as the built-in rules features. All these types of solutions are discussed later in this article, but following is a summary of the technologies based on whether or not they apply to the server or client.

Client-side rules developer technologies:
  • Rules Wizard "Run a Script" rules
  • Outlook Visual Basic for Applications solutions
  • Outlook COM add-in solutions
  • Custom Actions for the Rules Wizard
  • Exchange SDK Rule Component (Rule.dll)
Server-side rules developer technologies:
  • Exchange Server 5.5 Scripting Agents
  • Exchange 2000 Server Event Sinks
  • Exchange SDK Rule Component (Rule.dll)

Existing Solution or Product

<script type="text/javascript"></script> There is a variety of third-party products that have already been developed that are designed to provide functionality like rules. For more information about these products, visit one of the following Slipstick Web sites:
Slipstick.com (http://www.slipstick.com)
http://www.slipstick.com/addins/auto.htm (http://www.slipstick.com/addins/auto.htm)

Rules Wizard "Run a Script" Rules

<script type="text/javascript"></script> Outlook 2002 Visual Basic for Applications can be used in the Rules Wizard by using the "Run a Script" option. The "script" in this case must be Outlook Visual Basic for Applications. You cannot use another programming language, or host the code in an Outlook COM add-in. This feature is not available in Outlook 2000.

For additional information about how to create a script for the Outlook Rules Wizard, click the following article number to view the article in the Microsoft Knowledge Base:
306108  (http://support.microsoft.com/kb/306108/ ) How to Create a Script for the Rules Wizard

One of the key advantages of this approach is that you can use the built-in functionality of the Rules Wizard to determine which messages are processed. However, Outlook Visual Basic for Applications is not designed to be deployed, so use this approach only for your own personal use. For additional information about limitations related to deploying Outlook Visual Basic for Applications, click the article number below to view the article in the Microsoft Knowledge Base:
290779  (http://support.microsoft.com/kb/290779/EN-US/ ) OL2002: Managing and Distributing Outlook VBA Projects

Outlook Visual Basic for Applications Rules

<script type="text/javascript"></script> Instead of using the "Run a script" feature in the Rules Wizard, you can also create custom Visual Basic for Applications code in either Outlook 2000 or Outlook 2002 that functions as a rule. Typically, these solutions implement either the Item_Add event on the Inbox folder so that code runs whenever an item arrives in the Inbox, or the Application_ItemSend event so that code runs whenever an item is sent. An example of this approach is discussed in the following Knowledge Base articles:
292063  (http://support.microsoft.com/kb/292063/EN-US/ ) OL2002: How to Create a Custom Rule Using Visual Basic for Applications
235852  (http://support.microsoft.com/kb/235852/EN-US/ ) OL2000: How to Create a Custom Rule Using Visual Basic for Applications
Because Outlook Visual Basic for Applications code runs on the client, Outlook must be running for the code to run.

The following code sample is a rule that saves the attachments of a new e-mail message. Messages arriving with the subject "Test Att" and with attachments will have the attachments saved to the "C:\Test" folder with their file name. To implement this code, follow the steps in one of the Knowledge Base articles listed earlier in this article (Q292063 or Q235852), but substitute the following code instead of the code in those articles.
Dim WithEvents objInbox As Outlook.Items

Private Sub Application_Startup()
   Set objInbox = Session.GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub objInbox_ItemAdd(ByVal Item As Object)
   If Item.Class = olMail And Item.Subject = "Test Att" Then
      If Item.Attachments.Count > 0 Then
         Dim objAttachments As Outlook.Attachments
         Set objAttachments = Item.Attachments
         For Each objAttach In objAttachments
            ' Does not handle duplicate filename scenarios
            objAttach.SaveAsFile "C:\Test\" & objAttach.FileName
         Next
         Set objAttachments = Nothing
      End If
   End If
End Sub
				

Outlook COM Add-in Rules

<script type="text/javascript"></script> You can create a custom rule solution by developing an Outlook COM add-in. COM add-in solutions function as Outlook Visual Basic for Applications code does, but can be deployed. For additional information about how to create a Visual Basic COM add-in, click the article numbers below to view the articles in the Microsoft Knowledge Base:
230225  (http://support.microsoft.com/kb/230225/EN-US/ ) OL2000: How to Create a COM Add-in for Outlook
291163  (http://support.microsoft.com/kb/291163/EN-US/ ) OL2002: How to Create a COM Add-in for Outlook
316983  (http://support.microsoft.com/kb/316983/EN-US/ ) OL: A Sample COM Add-in That Uses the Visual Basic 6.0 Add-in Template
238228  (http://support.microsoft.com/kb/238228/ ) How To Build an Office 2000 COM Add-In in Visual Basic
The following Outlook COM add-in sample code will move Reply messages to another folder. E-mail messages with a subject beginning with "RE:" are moved to the folder "Sent Mail Archive", which is on the same level as the Inbox. You can modify the strings "RE:" and "Sent Mail Archive" to customize this sample.
Dim WithEvents objOL As Outlook.Application

Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal _
ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As _
Object, custom() As Variant)
    Set objOL = Application
End Sub

Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As _
      AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
   Set objOL = Nothing
End Sub

Private Sub objOL_ItemSend(ByVal Item As Object, Cancel As Boolean)
   Dim objDefFolder As Outlook.MAPIFolder
   Dim objSentFolder As Outlook.MAPIFolder
    
   Set objInboxFolder = Session.GetDefaultFolder(olFolderInbox)
   Set objSentFolder = obInboxFolder.Parent.Folders("Sent Mail Archive")
    
   Dim strSubject As String
   Dim strLeft As String
    
   strSubject = Item.Subject
   strLeft = Left(strSubject, 3)
   If strLeft = "RE:" Then
      Item.SaveSentMessageFolder objSentFolder
   End If
    
   Set objInboxFolder = Nothing
   Set objSentFolder = Nothing
End Sub
				

Custom Actions for the Outlook Rules Wizard

<script type="text/javascript"></script> Custom actions are developed by using C/C++ and must be installed on the computer running Outlook. Therefore, all custom actions are client-side rules. With custom actions, you can perform a specific action when a rule in the Rules Wizard is run. Outlook does not provide any custom actions, but many are available from third-party vendors. Documentation about developing a custom action is provided on MSDN. To view this documentation, visit the following Microsoft Web site:
http://msdn2.microsoft.com/en-us/library/ms981456.aspx (http://msdn2.microsoft.com/en-us/library/ms981456.aspx)
For additional information about custom actions, click the article number below to view the article in the Microsoft Knowledge Base:
196868  (http://support.microsoft.com/kb/196868/EN-US/ ) OL2000: Rules Wizard Custom Actions and Third Party Add-Ins
A sample Custom Action agent, named CRARUN, is available as part of the Exchange Server 5.5 SDK. For additional information about CRARUN, click the article number below to view the article in the Microsoft Knowledge Base:
151690  (http://support.microsoft.com/kb/151690/EN-US/ ) XCLN: What is the 'Custom' Rule Action For?
For more information about custom rules and actions, visit the following Slipstick Systems Web site:
All About Inbox Assistant and Rules Wizard Custom Actions (http://www.slipstick.com/emo/1997/up970804.htm#custom)

Server-Side Rules Using Exchange Event Scripts and Sinks

<script type="text/javascript"></script> For scenarios where you require a custom rule to run on the server, you can use the Exchange 5.5 Scripting Agent or Exchange 2000 event sinks. These types of solutions are especially well suited for particular public folders or a limited number of mailboxes. For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:
181036  (http://support.microsoft.com/kb/181036/EN-US/ ) INFO: Suitable Applications for Exchange Server Event Scripting
288156  (http://support.microsoft.com/kb/288156/ ) How To Create an Exchange 2000 Store Event Sink in Visual C++

Exchange SDK Rule Component

<script type="text/javascript"></script> The Exchange 5.5 SDK includes a Rules Component (Rule.dll) that you can use to programmatically create rules in a folder. These rules are run on either the client or server, depending on the type of rule created. For additional information about using the Rules Component, click the following article number to view the article in the Microsoft Knowledge Base:
251125  (http://support.microsoft.com/kb/251125/ ) HOWTO: Use the Rule.dll Sample to Create an Inbox Rule from Visual Basic
NOTE: Rules that are created by using the Rules Component are not displayed in the Outlook user interface.

Microsoft provides third-party contact information to help you find technical support. This contact information may change without notice. Microsoft does not guarantee the accuracy of this third-party contact information.

The third-party products that are discussed in this article are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, regarding the performance or reliability of these products.
分享到:
评论

相关推荐

    《Object-Oriented Programming with Object C》 英文高清原版 PDF

    《Object-Oriented Programming with Object C》是一本深入探讨面向对象编程(OOP)与Objective-C语言的专业书籍。Objective-C是Apple开发的一种强大的、面向对象的编程语言,主要用于iOS和macOS的应用程序开发。这...

    Paradigms of AI Programming - Peter Norvig

    Chapters on troubleshooting and efficiency are included, along with a discussion of the fundamentals of object-oriented programming and a description of the main CLOS functions. This volume is an ...

    A Novel Combination of Answer Set Programming with Description Logics

    本文献介绍了一种新颖的结合方式——将答案集编程(Answer Set Programming, ASP)与描述逻辑学(Description Logics, DL)融合在一起,以支持语义网(Semantic Web)。这种结合旨在通过一个平衡良好的接口来确保新...

    Beginning Programming with C++ For Dummies

    Even if you barely know what programming is, you can learn to “speak” the C++ language, install and use the compiler, work with loops, understand objects and classes, get rid of bugs, and write ...

    practical internet of things with javascript

    Practical Internet of Things with [removed] Build standalone exciting IoT projects with Raspberry Pi 3 and JavaScript (ES5/ES6) End to end solutions for IoT enthusiasts and web developers Key ...

    Practical Database Programming with Java

    A novel writing style is adopted to attract students or beginning programmers ...with the hope of avoiding the headaches caused by huge blocks of codes found in traditional database programming books....

    The Art of Computer Programming MMIX

    This multivolume work on the analysis of algorithms has long been recognized as the definitive description of classical computer science. The three complete volumes published to date already comprise ...

    The Art of Computer Programming, Volume 4 Fascicle 2

    Binary Decision Diagrams This multivolume work on the analysis of algorithms has long been recognized as the definitive description of classical computer science. The three complete volumes published...

    Packt.Hands-On.GPU.Computing.with.Python.1789341078.epub

    You will learn, by example, how to perform GPU programming with Python, and you'll look at using integrations such as PyCUDA, PyOpenCL, CuPy and Numba with Anaconda for various tasks such as machine ...

    《Learning.Network.Programming.with.Java》高清完整PDF版

    We start with the basics of networking and then explore how Java supports the development of client/server and peer-to-peer applications. The NIO packages are examined as well as multitasking and how ...

    Description of STM32F1 L4 L4+ G0 HAL and Low-layer drivers.rar

    Description of STM32F1 L4 L4+ G0 HAL and Low-layer drivers STMCubeTM is an STMicroelectronics original initiative to make developers' lives easier by reducing development efforts, time and cost. STM32...

    Programming.in.the.Large.with.Design.Patterns

    It starts with a general introduction to all types of programming patterns and goes on to describe 10 of the most popular design patterns in detail: Singleton, Iterator, Adapter, Decorator, State, ...

    Description of STM32F4 HAL and LL drivers.pdf

    ### STM32F4 HAL 和 LL 驱动概述 #### 一、引言与背景 随着嵌入式系统在各个领域的广泛应用,开发工具和软件的重要性日益凸显。STMicroelectronics 推出的 STM32CubeTM 系列,旨在简化开发流程、减少时间和成本...

Global site tag (gtag.js) - Google Analytics