Programming with the Security Update in Mind


In light of all the changes to Outlook described in the previous sections, your programs must be ready to respond to failed calls and to users clicking No in security warning dialog boxes. The easiest way to program your collaborative applications with the new security restrictions in mind is to leverage the built-in error trapping mechanism of the language you're using. For example, in Visual Basic or VBScript, you can make use of the built-in error handling capabilities. If a user clicks No in a dialog box, Outlook will return an error. Depending on how you want to handle the error in your program, you can either attempt the call again after informing the user what your program is doing or simply abort the action of your program.

The following code triggers the dialog box for sending a message. If the user responds negatively to the request to send, the program will display a message directing the user to an internal Web site that explains what the program is doing.

 Dim oApp As New Outlook.Application Dim oMailItem As Outlook.MailItem      Set oMailItem = oApp.CreateItem(olMailItem) oMailItem.To = "thomriz@microsoft.com" oMailItem.Subject = "New Message for you!" On Error Resume Next oMailItem.Send If Err.Number = 287 Then    'User said no!    MsgBox "This application, written by your IT department, " & _           "sends mail on your behalf.  To see the functionality " & _           "that this mail performs, please visit our internal help " & _           "at http://mycompany/app/myapp."    Err.Clear    oMailItem.Send    If Err.Number = 287 Then       MsgBox "The application cannot continue due to the user " & _              "canceling the Send action."     End If End If 



Programming Microsoft Outlook and Microsoft Exchange 2003
Programming MicrosoftВ® OutlookВ® and Microsoft Exchange 2003, Third Edition (Pro-Developer)
ISBN: 0735614644
EAN: 2147483647
Year: 2003
Pages: 227
Authors: Thomas Rizzo

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net