Click here to Skip to main content
11,578,213 members (65,847 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Office VSTO Events 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.
        _addIn.ItemSend();
    
    }
}


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

OR

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


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

Solution 1

Sounds like you want to use a static class or static member function:

http://msdn.microsoft.com/en-us/library/79b3xss3(v=vs.80).aspx[^]
  Permalink  
Comments
Tejas_Vaishnav at 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 at 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 at 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 at 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 at 25-May-12 1:42am
   
have you use a Office development using VS2008/VS2010 and VSTO 3.0
TRK3 at 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
good
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
    FormFactory.Instance.OutlookMailItem.Send();
}
  Permalink  

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

  Print Answers RSS
0 Richard MacCutchan 165
1 Peter Leow 150
2 OriginalGriff 120
3 Afzaal Ahmad Zeeshan 100
4 Frankie-C 85
0 OriginalGriff 880
1 Sergey Alexandrovich Kryukov 685
2 Abhinav S 573
3 F-ES Sitecore 420
4 Suvendu Shekhar Giri 393


Advertise | Privacy | Mobile
Web03 | 2.8.150603.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