Transferring rules between computers.

When transferring Outlook data storage (PST file) to another machine to a new installation, or when it's necessary to apply the earlier created rules on a computer on which leaving a message on a server (Home - Work) is applied, it is useful to create identical rules. This can be time consuming, and may be a problem when the copied rules are not created as in the original system.

In order to prevent it, you can use rules import wizard. In Menu/Tools/Rules and alerts click Options button. A new window will appear with two choices: Export and Import rules (Fig. 1.)

Exporting rules window
Fig. 1. Saving and restoring rules saved in "Office Data File (.rwz)" format.

Rules created this way can be easily transferred and applied to another machine.

Macro - the alternative method for rules creation.

Creating rules is carried out by a rule wizard. Although the range of available rules is wide, sometimes it is impossible to create a rule that will precisely suit our needs. Thanks to a built-in VBA editor, Outlook enables programming activities and pinning them to outgoing mail process.

The procedures presented below describe "Send a blind carbon copy of a message to adifferent address" and "Display a warning before sending a message with no subject, including the possibility to cancel this operation".

"Application_ItemSend" procedure must be pasted in ThisOutlookSession class and Outlook must be restarted. These instructions will not be applied without restarting Outlook .

Option Explicit
Private Sub Application_ItemSend(ByVal Item As Object, ByVal Cancel As Boolean)
    Dim oRecip As Recipient
    oRecip = Item.Recipients.Add("address@domain.com")
    oRecip.Type = olBCC
    oRecip.Resolve()
    oRecip = Nothing
End Sub
'or
Private Sub Application_ItemSend(ByVal Item As Object, ByVal Cancel As Boolean)
    Dim strSubject$, Prompt$
    strSubject = Item.Subject
    If Len(Trim(strSubject)) = 0 Then
        Prompt = "Subject is empty. Do you want to send this message?"
        If MsgBox(Prompt, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Checking before sending") = vbNo Then
            Cancel = True
        End If
    End If
End Sub

In the case of expanding our rules for outgoing mail, you should paste the "Application_ItemSend” procedure only once, and then refer in it to the rules placed in separate procedures. For example:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Call Blind_Carbon_Copy()
    Call No_subject(Item, Cancel) 'some procedures should be converted to functions
End Sub

On Outlook-center.com forum you can find many useful instructions and procedures.

© All rights reserved. No part or whole of this article may not be reproduced or published without prior permission
Oryginal article is public on this page

Shon Oskar – www.VBATools.pl


See Also