Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Add-ins for Outlook (http://www.outlookbanter.com/add-ins-outlook/)
-   -   Custom Add-In for Outlook Mail (http://www.outlookbanter.com/add-ins-outlook/81202-custom-add-outlook-mail.html)

pavanmuppidi November 4th 08 06:46 AM

Custom Add-In for Outlook Mail
 
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.

Ken Slovak - [MVP - Outlook] November 4th 08 03:02 PM

Custom Add-In for Outlook Mail
 
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" wrote in message
...

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



pavanmuppidi November 5th 08 11:31 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.

Ken Slovak - [MVP - Outlook] November 5th 08 04:58 PM

Custom Add-In for Outlook Mail
 
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" wrote in message
...

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



pavanmuppidi November 6th 08 07:11 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 November 6th 08 07:18 AM

public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
applicationObject = (Outlook.Application)application;
addInInstance = addInInst;

applicationObject.FolderContextMenuDisplay += new
Microsoft.Office.Interop.Outlook.ApplicationEvents _11_FolderContextMenuDisplayEventHandler(
applicationObject_FolderContextMenuDisplay);
}

void applicationObject_FolderContextMenuDisplay(Microso ft.Office.Core.CommandBar commandBar, Microsoft.Office.Interop.Outlook.MAPIFolder folder)
{
CommandBarButton button = (CommandBarButton)commandBar.Controls.Add(
MsoControlType.msoControlButton, 1, Type.Missing,
commandBar.Controls.Count - 1, true );
// Exception occurs on next line:
button.Tag = folder.EntryID + ";" + folder.StoreID;
button.Caption = "My Command";
}

this is the other piece of code i've tried.
but @ Extensibility.ext_ConnectMode , the error is coming.
MISSING NAMESPACE OR TYPE.
these are the namespaces i've used.
using System;
using System.Windows.Forms;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;

I'm totally new to these concepts. plz help.
where is the mistake?


Regards,
Muppidi.

Ken Slovak - [MVP - Outlook] November 6th 08 02:23 PM

Custom Add-In for Outlook Mail
 
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" wrote in message
...

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



pavanmuppidi November 7th 08 12:36 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.msoContr olButton)
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

Ken Slovak - [MVP - Outlook] November 7th 08 04:41 PM

Custom Add-In for Outlook Mail
 
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" wrote in message
...

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.msoContr olButton)
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



pavanmuppidi November 10th 08 04:32 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.msoC ontrolButton)
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


All times are GMT +1. The time now is 10:41 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com