SafeApplication object

 

SafeApplication object is designed to be used alongside the Outlook.Application object..

 

Unlike the Safe*Item objects, SafeApplication object is not MAPI based and hence can be used even if the bitness of the calling process (and Redemption) does not match the bitness of Outlook.

 

The example below intercepts the BeforePrint event (not exposed in the Outlook Object Model) and displays a warning if it finds a string that looks like a Social Security Number in the body of the message to be printed.

private Redemption.SafeApplication _safeApplication;

private Outlook.Application _application;

 

public TestForm()

{

    _application = new Outlook.Application();

    _safeApplication = new SafeApplication();

    _safeApplication.Item = _application;

    _safeApplication.BeforePrint += _safeApplication_BeforePrint;

}

 

private void _safeApplication_BeforePrint(object Item)

{

    Outlook.MailItem mailItem = Item as Outlook.MailItem;

    if (mailItem != null)

    {

        string body = mailItem.Body;

        body = body.Replace("\r", "").Replace("\n", "");

        Match ssnMatch = new Regex(@"(?<!\d)\d{3}([- ])\d{2}\1\d{4}(?!\d)").Match(body);

        if (ssnMatch.Success)

        {

            //unfortunately, the event is not cancelable

            MessageBox.Show("The message you are about to print appears to contain a "+

                            "Social Security Number.\n" +

                            "Please destroy the printout when you are done.",

                            "Printing from Outlook",

                            MessageBoxButtons.OK,

                            MessageBoxIcon.Warning);

        }

    }

}

 

Properties

Events

 


Derived from: IDispatch


Properties


ApplicationPath
string, read-only.
Returns the fully qualified path of the outlook.exe executable, e.g.
"C:\Program Files (x86)\Microsoft Office\root\Office16\OUTLOOK.EXE"
 
Bitness
integer, read-only.
Returns the Outlook bitness, 32 for the 32 bit version and 64 for the 64 bit version.
 

Events


BeforePrint(Item) The event fires before Outlook prints an item. The event is not cancelable.

Item - object. The item being printed, e.g. MailItem or AppoinntmentItem.
see the example above