Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: Custom Add-In for Outlook Mail

Geek News

Custom Add-In for Outlook Mail
pavanmuppidi <pavanmuppidi.355d70f[ at ]outlookbanter.com> 11/4/2008 6:46:09 AM
Hi

When i right click on a Outlook Mail, along with the other existing options i need to get one option like "Status" under which two sub-options like "Approve" and "Reject" should be there.

Upon selecting the Approve or Reject option, i should be able to automatically update a field in my database as "1" for Approve and "0" for Reject.

Can anyone help me in this regard.

Thanks in advance.

Regards,
Muppidi. -- pavanmuppidi
Re: Custom Add-In for Outlook Mail
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 11/4/2008 3:02:52 PM
Outlook version?

For Outlook 2003 or earlier you can hack something that will fire when an
item in the folder view (Explorer) is clicked, but you won't be able to tell
which item was clicked or even if the click was on an item or somewhere else
like the Navigation Pane. So that's pretty useless for what you want.

For Outlook 2007 there are new context menu events that fire from the
Application object, the one you'd want would be the ItemContextMenuDisplay()
event. That tells you which item or items were selected when the right-click
occurred. See the Object Browser Help on that event to see how it works.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"pavanmuppidi" <pavanmuppidi.355d70f[ at ]outlookbanter.com> wrote in message
news:pavanmuppidi.355d70f[ at ]outlookbanter.com...
[Quoted Text]
>
> Hi
>
> When i right click on a Outlook Mail, along with the other existing
> options i need to get one option like "Status" under which two
> sub-options like "Approve" and "Reject" should be there.
>
> Upon selecting the Approve or Reject option, i should be able to
> automatically update a field in my database as "1" for Approve and "0"
> for Reject.
>
> Can anyone help me in this regard.
>
> Thanks in advance.
>
> Regards,
> Muppidi.
>
>
>
>
> --
> pavanmuppidi

Re: Custom Add-In for Outlook Mail
pavanmuppidi <pavanmuppidi.3577cef[ at ]outlookbanter.com> 11/5/2008 11:31:28 AM
i'm trying to work out with VS 2005 and Outlook 2007.

can u brief me the steps to acheive this task or any helpful links .

still no progress from my side

trying with reference of this but getting errors.

http://msdn.microsoft.com/en-us/library/bb175110.aspx

looking forward for ur reply

Regards,
Muppidi. -- pavanmuppidi
Re: Custom Add-In for Outlook Mail
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 11/5/2008 4:58:33 PM
Yes, that's exactly what you need to use and the link has VBA code to use
the event. Have you tried pasting that code into your VBA project and
modifying it and then testing with that?

What errors are you getting? Did you try translating that VBA sample code to
whatever language you're using (either VB.NET or C#)? What code are you
trying to use?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"pavanmuppidi" <pavanmuppidi.3577cef[ at ]outlookbanter.com> wrote in message
news:pavanmuppidi.3577cef[ at ]outlookbanter.com...
[Quoted Text]
>
> i'm trying to work out with VS 2005 and Outlook 2007.
>
> can u brief me the steps to acheive this task or any helpful links .
>
> still no progress from my side
>
> trying with reference of this but getting errors.
>
> http://msdn.microsoft.com/en-us/library/bb175110.aspx
>
> looking forward for ur reply
>
> Regards,
> Muppidi.
>
>
>
>
> --
> pavanmuppidi

Re: Custom Add-In for Outlook Mail
pavanmuppidi <pavanmuppidi.3587a10[ at ]outlookbanter.com> 11/6/2008 7:11:57 AM
Private Sub Application_ItemContextMenuDisplay(ByVal CommandBar As Office.CommandBar, ByVal Selection As Selection)

Static intCounter As Integer

On Error GoTo ErrRoutine

' Increment or reset the counter
If intCounter < 1 Or intCounter > 100 Then
intCounter = 1
Else
intCounter = intCounter + 1
End If

' Add the menu.
Dim objMenu As Object
objMenu = CommandBar.Controls.Add(msoControlButton)
objMenu.Caption = "Displayed " & intCounter & " times"
objMenu.Enabled = False
objMenu.BeginGroup = True

EndRoutine:
On Error GoTo 0
Exit Sub

ErrRoutine:
MsgBox(Err.Number & " - " & Err.Description, _
vbOKOnly Or vbCritical, _
"Application_ItemContextMenuDisplay")

GoTo EndRoutine
End Sub

i'm getting error at

1) "Selection" (Type Selection is not defined)
2) "msoControlButton" (msoControlButton name not defined.)

i would like to do this in C#.Net. (or VB.Net)

could u suggest me to resolve this.

Regards,
Muppidi. -- pavanmuppidi
Re: Custom Add-In for Outlook Mail
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 11/6/2008 2:23:32 PM
Where did you put that code? Is it in the Outlook VBA project? You need to
make sure that you have project references set to Outlook and to Office, and
that the Outlook reference is ahead of any other application that exposes a
Selection object or collection.

You can also just fully qualify the code by changing Selection to
Outlook.Selection and changing msoControlButton to
Office.MsoControl.msoControlButton.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"pavanmuppidi" <pavanmuppidi.3587a10[ at ]outlookbanter.com> wrote in message
news:pavanmuppidi.3587a10[ at ]outlookbanter.com...
[Quoted Text]
>
> Private Sub Application_ItemContextMenuDisplay(ByVal CommandBar As
> Office.CommandBar, ByVal Selection As Selection)
>
> Static intCounter As Integer
>
> On Error GoTo ErrRoutine
>
> ' Increment or reset the counter
> If intCounter < 1 Or intCounter > 100 Then
> intCounter = 1
> Else
> intCounter = intCounter + 1
> End If
>
> ' Add the menu.
> Dim objMenu As Object
> objMenu = CommandBar.Controls.Add(msoControlButton)
> objMenu.Caption = "Displayed " & intCounter & " times"
> objMenu.Enabled = False
> objMenu.BeginGroup = True
>
> EndRoutine:
> On Error GoTo 0
> Exit Sub
>
> ErrRoutine:
> MsgBox(Err.Number & " - " & Err.Description, _
> vbOKOnly Or vbCritical, _
> "Application_ItemContextMenuDisplay")
>
> GoTo EndRoutine
> End Sub
>
> i'm getting error at
>
> 1) "Selection" (Type Selection is not defined)
> 2) "msoControlButton" (msoControlButton name not defined.)
>
> i would like to do this in C#.Net. (or VB.Net)
>
> could u suggest me to resolve this.
>
> Regards,
> Muppidi.
>
>
>
>
> --
> pavanmuppidi

Re: Custom Add-In for Outlook Mail
pavanmuppidi <pavanmuppidi.35a1fee[ at ]outlookbanter.com> 11/7/2008 12:36:59 PM
HI
i was able to debug without any errors now.
but this is just opening the outlook and going out of debug mode.
thats it.
its not hitting the break points.
i'm using only the ItemContextMenuDisplay event only.
how to go into debug mode and check whether the selected item's context menu is getting added with my customized item.

this is the code:

Private Sub Application_ItemContextMenuDisplay(ByVal CommandBar As Office.CommandBar, ByVal Selection As Outlook.Selection)

Static intCounter As Integer

On Error GoTo ErrRoutine

' Increment or reset the counter
If intCounter < 1 Or intCounter > 100 Then
intCounter = 1
Else
intCounter = intCounter + 1
End If

' Add the menu.
Dim objMenu As Microsoft.Office.Core.CommandBarControl
Dim cmbBar As Microsoft.Office.Core.CommandBar

objMenu = cmbBar.Controls.Add(Office.MsoControlType.msoControlButton)
objMenu.Caption = "Displayed " & intCounter & " times"
objMenu.Enabled = True
objMenu.BeginGroup = True

EndRoutine:
On Error GoTo 0
Exit Sub

ErrRoutine:
MsgBox(Err.Number & " - " & Err.Description, _
vbOKOnly Or vbCritical, _
"Application_ItemContextMenuDisplay")

GoTo EndRoutine
End Sub

please tell me what i'm missing.
what else events i need to add...?
i've given the references to Outlook 11.0 & 12.0 dlls and also to Office dll also.
still i'm not able to see my item in the context menu.
waiting for ur reply.

Thanks & regards,
Muppidi -- pavanmuppidi
Re: Custom Add-In for Outlook Mail
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 11/7/2008 4:41:23 PM
This is the same message you posted in the forms group. Please let's just
keep this to one thread in one group.

If the code compiles without errors and the event isn't being fired then you
aren't adding the event correctly. How are you adding the event?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"pavanmuppidi" <pavanmuppidi.35a1fee[ at ]outlookbanter.com> wrote in message
news:pavanmuppidi.35a1fee[ at ]outlookbanter.com...
[Quoted Text]
>
> HI
> i was able to debug without any errors now.
> but this is just opening the outlook and going out of debug mode.
> thats it.
> its not hitting the break points.
> i'm using only the ItemContextMenuDisplay event only.
> how to go into debug mode and check whether the selected item's context
> menu is getting added with my customized item.
>
> this is the code:
>
> Private Sub Application_ItemContextMenuDisplay(ByVal CommandBar As
> Office.CommandBar, ByVal Selection As Outlook.Selection)
>
> Static intCounter As Integer
>
> On Error GoTo ErrRoutine
>
> ' Increment or reset the counter
> If intCounter < 1 Or intCounter > 100 Then
> intCounter = 1
> Else
> intCounter = intCounter + 1
> End If
>
> ' Add the menu.
> Dim objMenu As Microsoft.Office.Core.CommandBarControl
> Dim cmbBar As Microsoft.Office.Core.CommandBar
>
> objMenu =
> cmbBar.Controls.Add(Office.MsoControlType.msoControlButton)
> objMenu.Caption = "Displayed " & intCounter & " times"
> objMenu.Enabled = True
> objMenu.BeginGroup = True
>
> EndRoutine:
> On Error GoTo 0
> Exit Sub
>
> ErrRoutine:
> MsgBox(Err.Number & " - " & Err.Description, _
> vbOKOnly Or vbCritical, _
> "Application_ItemContextMenuDisplay")
>
> GoTo EndRoutine
> End Sub
>
> please tell me what i'm missing.
> what else events i need to add...?
> i've given the references to Outlook 11.0 & 12.0 dlls and also to
> Office dll also.
> still i'm not able to see my item in the context menu.
> waiting for ur reply.
>
> Thanks & regards,
> Muppidi
>
>
>
>
> --
> pavanmuppidi

Re: Custom Add-In for Outlook Mail
pavanmuppidi <pavanmuppidi.35dc012[ at ]outlookbanter.com> 11/10/2008 4:32:09 AM
Imports System
Imports System.Windows.Forms
Imports Microsoft.VisualStudio.Tools.Applications.Runtime
Imports Outlook = Microsoft.Office.Interop.Outlook
Imports Office = Microsoft.Office.Core

public class ThisApplication
Private m_objApp As Outlook.Application = Nothing

Private Sub ThisApplication_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
AddHandler m_objApp.ItemContextMenuDisplay, AddressOf Application_ItemContextMenuDisplay



End Sub

Private Sub ThisApplication_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown
End Sub

Private Sub Application_ItemContextMenuDisplay(ByVal CommandBar As Office.CommandBar, ByVal Selection As Outlook.Selection)

Static intCounter As Integer

On Error GoTo ErrRoutine

' Add the menu.
If Selection.Count > 0 Then
Dim mail As Outlook.MailItem
mail = Selection(1)

Dim objMenu As Office.CommandBarButton

objMenu = CommandBar.Controls.Add(Office.MsoControlType.msoControlButton)
objMenu.Caption = "Displayed times"
objMenu.Enabled = True
objMenu.Visible = True

objMenu.BeginGroup = True

End If
EndRoutine:
On Error GoTo 0
Exit Sub

ErrRoutine:
MsgBox(Err.Number & " - " & Err.Description, _
vbOKOnly Or vbCritical, _
"Application_ItemContextMenuDisplay")

GoTo EndRoutine
End Sub


This is the code i'm using now. when i build the setup its getting created. but the event is not getting fired. let me know if i'm missing anything.

Regards,
Muppidi.
End Class -- pavanmuppidi
Re: Custom Add-In for Outlook Mail
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 11/10/2008 2:33:22 PM
Where are you instantiating your m_objApp object?

You are assigning an event handler to that object before it's ever
instantiated, assigned to an object that's Nothing.

In your startup event handler assign the Me.Application value to your
Outlook.Application object:

m_objApp = Me.Application

Do that before you assign the event handler.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"pavanmuppidi" <pavanmuppidi.35dc012[ at ]outlookbanter.com> wrote in message
news:pavanmuppidi.35dc012[ at ]outlookbanter.com...
[Quoted Text]
>
> Imports System
> Imports System.Windows.Forms
> Imports Microsoft.VisualStudio.Tools.Applications.Runtime
> Imports Outlook = Microsoft.Office.Interop.Outlook
> Imports Office = Microsoft.Office.Core
>
> public class ThisApplication
> Private m_objApp As Outlook.Application = Nothing
>
> Private Sub ThisApplication_Startup(ByVal sender As Object, ByVal e
> As System.EventArgs) Handles Me.Startup
> AddHandler m_objApp.ItemContextMenuDisplay, AddressOf
> Application_ItemContextMenuDisplay
>
>
>
> End Sub
>
> Private Sub ThisApplication_Shutdown(ByVal sender As Object, ByVal
> e As System.EventArgs) Handles Me.Shutdown
> End Sub
>
> Private Sub Application_ItemContextMenuDisplay(ByVal CommandBar As
> Office.CommandBar, ByVal Selection As Outlook.Selection)
>
> Static intCounter As Integer
>
> On Error GoTo ErrRoutine
>
> ' Add the menu.
> If Selection.Count > 0 Then
> Dim mail As Outlook.MailItem
> mail = Selection(1)
>
> Dim objMenu As Office.CommandBarButton
>
> objMenu =
> CommandBar.Controls.Add(Office.MsoControlType.msoControlButton)
> objMenu.Caption = "Displayed times"
> objMenu.Enabled = True
> objMenu.Visible = True
>
> objMenu.BeginGroup = True
>
> End If
> EndRoutine:
> On Error GoTo 0
> Exit Sub
>
> ErrRoutine:
> MsgBox(Err.Number & " - " & Err.Description, _
> vbOKOnly Or vbCritical, _
> "Application_ItemContextMenuDisplay")
>
> GoTo EndRoutine
> End Sub
>
>
> This is the code i'm using now. when i build the setup its getting
> created. but the event is not getting fired. let me know if i'm missing
> anything.
>
> Regards,
> Muppidi.
> End Class
>
>
>
>
> --
> pavanmuppidi

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net