4406 Extending Outlook 2000 with COM Addins, Visual Basic for Applications, and the Outlook Object M - PowerPoint PPT Presentation

Loading...

PPT – 4406 Extending Outlook 2000 with COM Addins, Visual Basic for Applications, and the Outlook Object M PowerPoint presentation | free to view - id: e93e2-ZDc1Z



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

4406 Extending Outlook 2000 with COM Addins, Visual Basic for Applications, and the Outlook Object M

Description:

'OutAddIn' class can expose Public properties and methods for VBScript in Outlook Forms ... Messaging Into Your Solutions Using Microsoft Outlook 2000 ... – PowerPoint PPT presentation

Number of Views:454
Avg rating:3.0/5.0
Slides: 33
Provided by: randy123
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: 4406 Extending Outlook 2000 with COM Addins, Visual Basic for Applications, and the Outlook Object M


1
Extending Outlook 2000 with COM Add-ins, Visual
Basic for Applications, and the Outlook Object
Model (Part 2) Randy ByrnePresident/CEO Micro
Eye, Inc.http//www.microeye.com
2
(No Transcript)
3
Agenda
  • Demo COM Add-in and drill down into VB 6.0 code
  • What is IDTExtensibility2?
  • Using COM Add-in template in VB6
  • Adding PropertyPages to your Add-in
  • Debugging COM Add-ins
  • Security and deployment
  • Plus tips and tricks along the way!

4
Items Command BarCOM Add-in demo
  • Simple - Create all Item types from Command Bar
  • Intermediate - Create HTML Messages from Word,
    Excel, PowerPoint
  • Advanced - Use CDO to display drop-down combo box
    of custom forms

5
IDTExtensibility2
  • OnConnection
  • Called when Add-in is first loaded
  • Passed the Outlook application object
  • OnDisconnection
  • Clean up object references and remove command
    bars if necessary
  • OnStartupComplete
  • Called when Outlook has finished booting

6
IDTExtensibility2
  • OnBeginShutdown
  • Called when Outlook is about to shutdown
  • Entire Object Model is still available
  • Persist settings to registry if necessary
  • OnAddInsUpdate
  • Called whenever the COMAddIns collection oject
    changes
  • Use to determine status of other Add-ins

7
COMAddIns Object
Application
COMAddIns
Count
COMAddIn
Description
Connect
Guid
ProgID
8
COMAddIns Object
  • Member of Office 2000 Object Model
  • Determine installed Add-ins
  • Toggle Connect state of an Add-in
  • Disconnect an Add-in during OnConnection event
    depending upon other installed applications
  • Disconnect Add-in during update of DLL while
    Outlook is running

9
COMAddIns Object
  • Set colAddIns Application.COMAddIns
  • intAddIns colAddIns.Count
  • If intAddIns Then
  • ReDim avarArray(intAddIns - 1, 2)
  • For intCount 1 To intAddIns
  • Set objAddIn colAddIns.Item(intCount)
  • avarArray(intCount - 1, 0) _
  • objAddIn.Description
  • If objAddIn.Connect True Then
  • avarArray(intCount - 1, 1) "True"
  • Else
  • avarArray(intCount - 1, 1) "False"
  • End If
  • avarArray(intCount - 1, 2)
    objAddIn.ProgId
  • Next
  • lstAddIns.List avarArray
  • End If

10
COM Add-In Template
  • Available on Conference CD
  • References
  • Outlook 9.0 Object Library
  • Add-In Designer Object Library
  • Office 9.0 Object Library (CommandBars)
  • Other Object Libraries as required (CDO, ADO,
    ADSI, Routing Objects)
  • Provides Code framework for declaring events at
    the Item level
  • Connect and OutAddIn classes

11
Dual Class COM Add-ins
  • Pro
  • Plug-in Architecture
  • Connect class for COM Add-in plumbing
  • OutAddIn class can expose Public properties
    and methods for VBScript in Outlook Forms
  • Con
  • Added Complexity
  • VB Only (not available using MOD)

12
COM Add-In Template
_Connect
IUnknown
COM Add-In
_OutAddIn
IDispatch
Connect (Add-In Designer)
OutAddIn (Base Class)
_IDTExtensibility2
13
Connect Class
  • Implements IDTExtensibility2
  • Use OnConnection event to create a new instance
    of base class (OutAddIn)
  • Pass Application object to InitHandler
  • Pass ProgID to InitHandler
  • ProgID needed for COM Add-in CommandBarButton and
    CommandBarComboBox objects

14
OnConnection Event
  • 'Declarations
  • Implements IDTExtensibility2
  • Private gBaseClass As New OutAddIn
  • Private Sub IDTExtensibility2_OnConnection _
  • (ByVal Application As Object, _
  • ByVal ConnectMode As _
  • AddInDesignerObjects.ext_ConnectMode, _
  • ByVal AddInInst As Object, custom() As
    Variant)
  • 'Create and Initialize a base class
  • gBaseClass.InitHandler _
  • Application, AddInInst.ProgId
  • End Sub

15
InitHandler Procedure
  • Analogous to Application_Startup
  • Use friend instead of public or private
  • Instantiate object variables declared WithEvents
  • Important objects for InitHandler
  • Application
  • NameSpace
  • Explorers
  • Explorer
  • Inspectors

16
InitHandler Procedure
  • Friend Sub InitHandler(olApp As
    Outlook.Application, _ strProgID As String)
  • 'Declared WithEvents
  • Set objOutlook olApp
  • 'Instantiate a public module-level Outlook
  • 'application variable
  • Set golApp olApp
  • gstrProgID strProgID
  • 'Declared WithEvents
  • Set objNS objOutlook.GetNamespace("MAPI")
  • Set colExpl objOutlook.Explorers
  • Set colInsp objOutlook.Inspectors
  • Set objExpl objOutlook.ActiveExplorer
  • End Sub

17
OutAddIn Class
  • Contains the working code for your COM Add-in
  • NewInspector Event lets you raise events at the
    Item Level
  • Be sure to tear down objects in this class during
    OnDisconnection event
  • Set golApp Nothing

18
Cleanup Tips
  • Prevent Outlook from remaining in memory due to
    your COM Add-in
  • Call UnInitHandler procedure
  • Set Object Variables to Nothing
  • Use Explorer_Close event to call UnInitHandler
  • Use Inspector_Close event to call UnInitHandler

19
UnInitHandler
  • Friend Sub UnInitHandler()
  • 'You must dereference all objects in this
    proc
  • 'or Outlook will remain in memory
  • 'If you have created an objMailItem variable,
  • 'be sure to Set objMailItem Nothing
  • Set objInsp Nothing
  • Set objExpl Nothing
  • Set colInsp Nothing
  • Set colExpl Nothing
  • Set objNS Nothing
  • Set golApp Nothing
  • Set objOutlook Nothing
  • End Sub

20
Command Bars (Recipe 1)
  • Private WithEvents CBBMyButton As
    Office.CommandBarButton
  • Use InitHandler to call a procedure that adds
    button to Explorer object
  • Use Item-level open event to call a procedure
    that adds button to Inspector object
  • Create Click Procedure for CBBMyButton
  • Write code in Click Procedure

21
Command Bars (Recipe 2)
  • Call CreateAddInCommandBarButton or
  • CreateAddInCommandBarComboBox
  • Be sure to pass ProgID
  • Notice that .OnAction lt! and strProgID and
    gt

22
Command Bars (Recipe 3)
  • Use Explorers collection for Explorer Command
    Bars that maintain state
  • See ExplWrap.cls in Items Command Bar example
  • Use SelectionChange event to establish state when
    New Explorer window first opens
  • Be sure to destroy collection objects

23
Property Pages
  • Application OptionsPagesAdd Event adds Property
    Page to Tools Options dialog box
  • Namespace OptionsPagesAdd Event adds Property
    Page to Folder Properties dialog box
  • Use Windows registry to persist settings for your
    COM Add-in

24
Property Pages (Recipe)
  • Create Visual Basic ActiveX control project
  • Implements Outlook.PropertyPage
  • PropertyPage Events
  • Apply
  • Dirty
  • GetPageInfo
  • Read settings from Registry (InitProperties)
  • Write settings to Registry (Apply)

25
Add-in Registry Settings
  • COM server settings in HKCR
  • COM Add-In specific settings
  • HKLM HKCU\Software\Microsoft\Office\Outlook\A
    ddins\ProgID
  • FriendlyName (String)
  • FileName (String)
  • LoadBehavior (DWORD bit mask)determines
    connection mode
  • Custom settings as required

26
Property Pages Demo
27
Debugging COM Add-ins
  • Load COM Add-in project in Visual Basic
  • Insert breakpoints, stop statements, or watches
  • Press CTRL F5 to start with full compile
  • Launch Outlook

28
Debugging Tips
  • Check Version Compatibility Option in Project
    Properties
  • Binary compatibility
  • Project compatibility
  • Use COM Add-Ins dialog box to unload and reload
    your COM Add-In
  • Make sure you are in run mode

29
Deployment
  • Use Package and Deployment Wizard
  • Standard Setup
  • Uses Add/Remove programs
  • Web-based Setup
  • Add/Remove not available
  • URL on corporate intranet
  • CODEBASE tags in Folder Home Page

30
Deployment Plus Installer
  • Use Windows Installer to add components for your
    COM Add-in
  • CDO 1.21 not installed by standard Office 2000
    Setup
  • Reference Windows Installer Object Library for
    programmatic install
  • Install additional components during
    On_Connection event
  • Consider Installer failure strategy
  • See modInstaller code in Items Command Bar sample
    code

31
Security
  • Security level defaults to medium
  • Outlook security levels
  • Low - No security
  • Medium - Signed Add-in runs, user prompted when
    unsigned Add-in loaded
  • High - Add-Ins must be signed, unsigned Add-Ins
    wont load
  • Exception All COM Add-ins trusted by default

32
Security Settings
  • Manually configured with registry key
  • HKCU\Software\Microsoft\Office\9.0\Outlook\Securi
    ty
  • Level (DWORD, 1 Low, 2 Medium,3 High)
  • DontTrustInstalledFiles (DWORD)(0 Trust, 1
    Dont trust)
  • No UI for DontTrustInstalledFiles in Outlook
  • Use a code-signing certificate to sign the
    released version of your Add-in

33
Where To Go From Here
  • Chapter 9, Raise Events and Move to the Head of
    the Class
  • Chapter 13, Creating COM Add-Ins with Visual
    Basic

34
Additional Sessions
  • 4-320 Using, Building and Extending Outlook 2000
    Team Folders
  • 4-417 Building Applications with Microsoft
    Exchange "Platinum" (Part 1)
  • 4-418 Building Applications with Microsoft
    Exchange "Platinum" (Part 2)  
  • 2-315 Integrating Messaging Into Your Solutions
    Using Microsoft Outlook 2000
  • 4-315 New Tools for Microsoft Exchange
    Application Development
  • 4-425 Integrating Data from SQL Server and
    Exchange into Microsoft Outlook 2000 Applications

35
Questions And Answers
36
(No Transcript)
About PowerShow.com