A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Custom Add-In for Outlook Mail



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 4th 08, 06:46 AM
pavanmuppidi pavanmuppidi is offline
Junior Member
 
First recorded activity at Outlookbanter: Nov 2008
Posts: 6
Question 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.
Ads
  #2  
Old November 4th 08, 03:02 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default 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
news

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


  #3  
Old November 5th 08, 11:31 AM
pavanmuppidi pavanmuppidi is offline
Junior Member
 
First recorded activity at Outlookbanter: Nov 2008
Posts: 6
Default

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.
  #4  
Old November 5th 08, 04:58 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default 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
news

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


  #5  
Old November 6th 08, 07:11 AM
pavanmuppidi pavanmuppidi is offline
Junior Member
 
First recorded activity at Outlookbanter: Nov 2008
Posts: 6
Question

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.

Last edited by pavanmuppidi : November 6th 08 at 07:14 AM.
  #6  
Old November 6th 08, 07:18 AM
pavanmuppidi pavanmuppidi is offline
Junior Member
 
First recorded activity at Outlookbanter: Nov 2008
Posts: 6
Question

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.
  #7  
Old November 6th 08, 02:23 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default 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
news

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


  #8  
Old November 7th 08, 12:36 PM
pavanmuppidi pavanmuppidi is offline
Junior Member
 
First recorded activity at Outlookbanter: Nov 2008
Posts: 6
Question

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
  #9  
Old November 7th 08, 04:41 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default 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
news

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


  #10  
Old November 10th 08, 04:32 AM
pavanmuppidi pavanmuppidi is offline
Junior Member
 
First recorded activity at Outlookbanter: Nov 2008
Posts: 6
Default

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
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create and call Microsoft Custom Form in Outlook 2003 Mail? Naval kishore Outlook - Using Forms 1 May 8th 08 01:53 PM
How to have custom mail forms integrated to Outlook? MeAgin Outlook - Using Forms 3 December 11th 06 12:22 PM
Creating Custom Mail Form Sam Outlook - Using Forms 3 September 19th 06 07:40 PM
automatically send e-mail when closing a custom outlook form Keefo Outlook - Using Forms 1 May 27th 06 02:22 PM
Custom Mail Fields Ian Mackenzie Outlook and VBA 2 March 31st 06 02:50 PM


All times are GMT +1. The time now is 06:10 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-2025 Outlook Banter.
The comments are property of their posters.