Click here to Skip to main content
11,922,320 members (39,991 online)
Rate this:
Please Sign up or sign in to vote.
See more: Office VSTO Outlook AddIn , +
I have develop one Custom addin for Outlook.

and i have put some custome button on Outlook Ribbon bar also.

now what is my problem is, i want to call one method declared on ThisAddin class (which is by default created by Addin), from by custom button's(which is placed on RibbonBar) Click event.

for this right now i am using a new instance of ThisAddin class to call that method, but i will creating some issues. so i want to know any other method with out creating new instance of ThisAddin class can i call my method from Button Click event.

or can i call Send Item event from by Button Click event.

what i am using right now is like this....

private void btnProtect_Click(object sender, RibbonControlEventArgs e)
    using (ThisAddIn _addIn = new ThisAddIn())
        //Here what i do is Create one new Instance of ThisAddin Class
        //And Access it's ItemSend() method throught it.

What i want is with out createing any new instance i want to call that method from my ribbon -> button -> click event


I want to Fire a Application.ItemSend event from Ribbon Control Button Click Event.

please provide your valuable suggestions.
Posted 23-May-12 0:33am
Edited 23-May-12 1:01am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Sounds like you want to use a static class or static member function:[^]
Tejas_Vaishnav 24-May-12 0:19am
I appriciate your try, but that not what i want.
while developing a Office addin in some case we want to access the amin addin calss methods or events from custom menubar's or ribbonbar's. and that what i want.
TRK3 24-May-12 13:19pm
I'm confused about what you want to do.

If you don't want to create a new instance, then you obviously want to refer to an existing instance.

Is there only one instance or are there multiple instances?

If there is only one, then a static class solves your problem.

If there are multiple instances, then which instance do you want to refer to?
Tejas_Vaishnav 25-May-12 1:40am
ThisAddin Class is already given by the VSTO template. so we can not make it as a static or sealed class.
Tejas_Vaishnav 25-May-12 1:41am
and the Ribbon bar is attached inside that ThisAddin Class automatically by setting some property of Ribbon Contarol. and i want to call a Send button click event from my ribbon bar button click.
Tejas_Vaishnav 25-May-12 1:42am
have you use a Office development using VS2008/VS2010 and VSTO 3.0
TRK3 25-May-12 13:34pm
I haven't done VSTO / Office development, but the documentation says that you should not instantiate the class yourself and that it is instantiated when your addin is loaded.

I would think it should be available as Application.thisAddin or Globals.thisAddin or something like that... Isn't it?
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Finally i found the solution for this.
what i do for this is to access the mail item and use mail items send() method so it will fire Application_Item Send event automatically.

like this.

private void btnProtect_Click(object sender, RibbonControlEventArgs e)
    //FormFactory is User Defined Class to store local Variables
    //Here i already store my MailItem Object

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 493
1 Dave Kreskowiak 285
2 Sergey Alexandrovich Kryukov 243
3 Richard MacCutchan 155
4 ppolymorphe 135
0 OriginalGriff 7,231
1 KrunalRohit 4,530
2 Sergey Alexandrovich Kryukov 3,356
3 George Jonsson 2,865
4 Suvendu Shekhar Giri 2,216

Advertise | Privacy | Mobile
Web04 | 2.8.151120.1 | Last Updated 30 May 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100