Outlook events

  • Thread starter Paulo Braz Figueiredo
  • Start date
P

Paulo Braz Figueiredo

Hi,
I’m developing an Outlook Add-in in c#. I need to catch a Reminder event.
When the reminder event fires I need to perform custom instructions instead
of the default instructions. Anybody knows how this is possible to archive?
Anybody have examples of code in C#...
 
K

Ken Slovak - [MVP - Outlook]

The Application.Reminders collection can be gotten and it has events for
ReminderFire, which returns a Reminder object you can work with. It also has
BeforeReminderShow, which can be canceled. That fires when the reminders
window is about to be displayed.

Use the Object Browser to review all the things that are available in the
Reminders collection and Reminder objects.
 
P

Paulo Braz Figueiredo

Hi, Ken Slovak,
I looked to your tips and tried to solve my problem. I’m having problems
with the trigger!
In the add-in I’m doing:
this.Reminders.ReminderFire += new System.EventHandler(reminder_fire);
private void reminder_fire(arguments) {
/* code */
}
I don’t know how to program the reminder_fire function! I don’s know what to
put in the arguments!! I don’t have any documentation about it! Do you know
how to program it?
 
K

Ken Slovak - [MVP - Outlook]

Have you looked in the Object Browser? It has information on every Outlook
method, property and event with all the calling and return arguments.
 
P

Paulo Braz Figueiredo

Hi, Ken Slovak,
Thanks for the tip about de “Object Inspector†ïŠ.
I’m doing:
private void ThisApplication_Startup(object sender, System.EventArgs e) {
this.Reminders.ReminderFire += new
Outlook.ReminderCollectionEvents_ReminderFireEventHandler(this.reminder_fire);
}

private void reminder_fire(Microsoft.Office.Interop.Outlook.Reminder
reminder) {
MessageBox.Show("Inside Reminder Fire");
}

But nothing appends when a reminder fires! I don’t know what’s wrong. Do you
know why doesn’t work? This is not the way to program a Event Handler for the
reminders?
 
K

Ken Slovak - [MVP - Outlook]

Your declarations look wrong. Also it's usually good practice to assign a
private variable in these cases to something like the Outlook.Reminders
collection. Your code would probably work however without the private
variable.

I tested this here and my code fired a message box when a reminder fired.
I'm showing only part of the ThisApplication class.

I used VSTO V3 running on Visual Studio 2005 and Outlook 2007 to test this
with:

public partial class ThisApplication
{
private Outlook.Reminders m_Reminders;

private void ThisApplication_Startup(object sender, System.EventArgs
e)
{
m_Reminders = this.Reminders;

m_Reminders.ReminderFire += new
Microsoft.Office.Interop.Outlook.ReminderCollectionEvents_ReminderFireEventHandler(Reminders_ReminderFire);
}

#region event handlers
private void
Reminders_ReminderFire(Microsoft.Office.Interop.Outlook.Reminder
ReminderObject)
{
MessageBox.Show("Reminder Fire");
}
#endregion
 
P

Paulo Braz Figueiredo

Hi Ken Slovak,
you have reason. I tried without the private member and it doesn’t woks. I
have my problem resolved but I don’t understand the importance of the private
member!
I’m doing:
this.reminders = this.Reminders;
reminders.ReminderFire += new
Microsoft.Office.Interop.Outlook.ReminderCollectionEvents_ReminderFireEventHandler(Reminders_ReminderFire);
Where reminders is a private member.
But if I do:
this.Reminders.ReminderFire += new
Microsoft.Office.Interop.Outlook.ReminderCollectionEvents_ReminderFireEventHandler(Reminders_ReminderFire);
It doesn’t work! And I do not understand why! ï‹
Thanks for the help on this subjet.
 
K

Ken Slovak - [MVP - Outlook]

Most likely because the event handler is out of scope or has been garbage
collected by the time the event fires. A private variable that remains in
scope would prevent that.

It's the same case if you need to track multiple Inspectors or Explorers and
handle a button click separately in each one. The event might fire the first
time but to ensure it always remains available as long as that Inspector or
Explorer is open you do something like putting the object reference in a
hashtable or dictionary or collection.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top