Public Class ThisAddIn
Dim _Explorers As Outlook.Explorers
Dim _Inspectors As Outlook.Inspectors
Dim _NameSpace As Outlook.NameSpace
Dim settingsFrm As Form = New frmSettings
Public Sub InitializeMenu()
Dim _menuBar As Office.CommandBar = Me.Application.ActiveExplorer().CommandBars.ActiveMenuBar
Dim _helpMenuIndex As Object
Try
_helpMenuIndex = _menuBar.Controls("Help").Index
Catch ex As ArgumentException
_helpMenuIndex = _menuBar.Controls.Count
End Try
Dim _topMenu As Office.CommandBarPopup = _menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, Type.Missing, Type.Missing, _helpMenuIndex, True)
If _topMenu IsNot Nothing Then
_topMenu.Caption = "menu1"
Try
Dim newButton As Microsoft.Office.Core.CommandBarButton
newButton = CType(_topMenu.Controls.Add(Microsoft.Office.Core.MsoControlType.msoControlButton), Microsoft.Office.Core.CommandBarButton)
newButton.Caption = "button1"
newButton.FaceId = 1044
AddHandler newButton.Click, AddressOf buttonOne_Click
Catch ex As System.Exception
Debug.Print("Could Not Create Button ""button1""...")
End Try
_topMenu.Visible = True
End If
End Sub
Public Sub buttonOne_Click(ByVal barButton As Microsoft.Office.Core.CommandBarButton, ByRef someBool As Boolean)
If settingsFrm.Visible = False Then
settingsFrm.Show()
End If
End Sub
Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
Me.InitializeMenu()
_NameSpace = Me.Application.GetNamespace("MAPI")
_Explorers = Me.Application.Explorers
_Inspectors = Me.Application.Inspectors
AddHandler _Explorers.Application.NewMailEx, AddressOf Application_NewMail
End Sub
Sub Application_NewMail(ByVal EntryID As String)
Dim newMail As Outlook.MailItem = _Explorers.Application.Session.GetItemFromID(EntryID, System.Reflection.Missing.Value)
Dim mSubject As String = newMail.Subject
Dim mBodyType As Outlook.OlBodyFormat = newMail.BodyFormat
Dim mBody As String = newMail.Body
Dim mHTMLBody As String = newMail.HTMLBody
Dim mAttachements As Outlook.Attachments = newMail.Attachments
Dim mSenderAddressType As String = newMail.SenderEmailType
Dim mSenderAddress As String = newMail.SenderEmailAddress
Dim mSenderName As String = newMail.SenderName
End Sub
Private Sub ThisAddIn_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown
End Sub
End Class
|