Johan Nordberg

Hi,

I'm working on a simple Outlook Addin that basically just simplifies some built in tasks such as assigning specific categories and adding reminders. I've added a custom ribbon tab to the contact item form.

One thing that I can't figure out is how to add a reminder with my own title and reminder date to the contact item. Does anyone know how to do this

I'm using VSTO2005SE, Outlook 2007 and C#.

Thanks!

// Johan



Re: Visual Studio Tools for Office Add reminder to Outlook ContactItem

X4U

Hello Johan,

i'm not sure but maybe this is what you want to do...

Code Snippet

object missing = Missing.Value;

// get the Outlook Application Object

Outlook.Application outlookApplication = new Outlook.Application();

// get the namespace object

Outlook.NameSpace nameSpace = outlookApplication.GetNamespace("MAPI");

// Logon to Session, here we use an already opened Outlook

nameSpace.Logon(missing, missing, true, true);

if (nameSpace.Session != null) panelSession.BackColor = Color.GreenYellow;

// Create a new Contact and save it

Outlook.ContactItem newContact = (Outlook.ContactItem)outlookApplication.CreateItem(Outlook.OlItemType.olContactItem);

newContact.FirstName = "Victor";

newContact.LastName = "Frankenstein";

newContact.Save();

Outlook.AppointmentItem customReminder = (Outlook.AppointmentItem)outlookApplication.CreateItem(Outlook.OlItemType.olAppointmentItem);

// Set a customized subject..

customReminder.Subject = "This is Frankie's reminder";

// when should the reminder occur

customReminder.Start = DateTime.Now.AddMinutes(5);

customReminder.End = customReminder.Start;

// Should we set the appointment as AllDayEvent

customReminder.AllDayEvent = false;

// Enable the Reminder `

customReminder.ReminderSet = true;

// Link the reminder to the contactItem

// Now you can see and change it in the contact's activities.

customReminder.Links.Add(newContact);

customReminder.Save();

// Release COM Objects

Marshal.ReleaseComObject(customReminder);

Marshal.ReleaseComObject(newContact);

// logoff from namespace

nameSpace.Logoff();

panelSession.BackColor = Color.Black;

// release resources

Marshal.ReleaseComObject(nameSpace);

Marshal.ReleaseComObject(outlookApplication);

GC.WaitForPendingFinalizers();

GC.Collect();

Hope this helps,

greets, Helmut






Re: Visual Studio Tools for Office Add reminder to Outlook ContactItem

Johan Nordberg

Thank you for you reply!

It's not exactly the answer i was looking for, however this is still really interesting! I'm not sure what the "customReminder.Links.Add(newContact);" actually does How do this affect Outlook

What I was looking for was a way to edit the Follow up-label. It's not that important. I still got the reminder set and the default text is the name of the contact which is good enough.

There is a MarkAsTask() and ClearTaskFlag() method on the contact item. There is also a ReminderTime and ReminderSet property that works fine.

// Johan






Re: Visual Studio Tools for Office Add reminder to Outlook ContactItem

Sue Mosher - Outlook MVP

The follow-up label is not exposed as a ContactItem property, but is available through the PropertyAccessor object with the schema name http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/8530001E.

You might want to look at the ContactItem.TaskSubject property as well.

Links.Add adds a link to a contact, visible in the Contacts controls at the bottom of the first page of the contact form. Those controls are off by default, but can be turned on in Tools | Options.





Re: Visual Studio Tools for Office Add reminder to Outlook ContactItem

Johan Nordberg

Thank you! I think I tried the TaskSubject, but I think that it worked the way I wanted. I will look at the PropertyAccessor.

Thanks for your help!