nFew days back , questioned was thrown at me like – hey dude , have you ever tried extending ribbon in outlook? and my answer at that point was ‘No’. then next question was – is it possible to have some buttons in the ribbon which will allow you to create new meeting request and mails with predefined data and recipients?
n
nQuestion did sound interesting to me , and that immediately taken me in front of machine. I opened up VS 2010 to see what can be done.
nIt is easy to extend ribbon of Office applications using VS 2010 , as it gives you the project template.
nI will not cover up how to create new ribbon and add buttons on it but here is what I learned on that evening – how to create new meeting request and new mails with predefined contents.
nJust added two buttons on my custom ribbon , and added code behind of custom ribbon and buttons
n
n
n
n
nQuestion did sound interesting to me , and that immediately taken me in front of machine. I opened up VS 2010 to see what can be done.
nIt is easy to extend ribbon of Office applications using VS 2010 , as it gives you the project template.
nI will not cover up how to create new ribbon and add buttons on it but here is what I learned on that evening – how to create new meeting request and new mails with predefined contents.
nJust added two buttons on my custom ribbon , and added code behind of custom ribbon and buttons
n
n
n
nprivate Applicationnm_outlookApp;
n
nprivate Explorernm_outlookActiveWindow;
n
n
- n
- To create new mail programmatically
n
n nn
n
ntry
n
n{
n
n m_outlookApp = Globals.ThisAddIn.Application;
n
n m_outlookActiveWindown= m_outlookApp.ActiveExplorer();
n
n
n
n MailItem mailItem = m_outlookApp.CreateItem(OlItemType.olMailItem) asnMailItem;
n
n
n
n if (mailItem != null)
n
n {
n
n mailItem.Bodyn= “Add Your Contents Here..”;
n
n mailItem.Subjectn= “Add Appointment Subject Here..”;
n
n mailItem.Ton= “target.user@smtp.com”;
n
n mailItem.Save();
n
n mailItem.Display(true);
n
n Marshal.ReleaseComObject(mailItem);
n
n }
n
n }
n
n catch (System.Exceptionnex)
n
n {
n
n System.Windows.Forms.MessageBox.Show(“Error:n” + ex.Message);
n
n }
n
n
- n
- To create new meeting request programmatically
n
n
n
n
ntry
n
n{
n
n m_outlookAppn= Globals.ThisAddIn.Application;
n
n m_outlookActiveWindown= m_outlookApp.ActiveExplorer();
n
n
n
n AppointmentItem appItem = m_outlookApp.CreateItem(OlItemType.olAppointmentItem) as AppointmentItem;
n
n
n
n if (appItem != null)
n
n {
n
n appItem.Bodyn= “Add Your Contents Here..”;
n
n appItem.Subjectn= “Add Appointment Subject Here..”;
n
n appItem.RequiredAttendeesn= “target.user1@smtp.com;target.user2@smtp.com”;
n
n appItem.OptionalAttendeesn= “optional.user1@smtp.com”;
n
n appItem.Startn= DateTime.Now.AddHours(1);
n
n appItem.Endn= DateTime.Now.AddHours(2);
n
n appItem.Save();
n
n appItem.Display(true);
n
n Marshal.ReleaseComObject(appItem);
n
n }
n
n }
n
n catch (System.Exceptionnex)
n
n {
n
n System.Windows.Forms.MessageBox.Show(“Error:n” + ex.Message);
n
n }
n
n
n
n
n
nReferences:
n
nhttp://blogs.msdn.com/b/mcsuksoldev/archive/2010/10/01/building-and-deploying-an-outlook-2010-add-in-part-1-of-2.aspx
n
nhttp://www.add-in-express.com/creating-addins-blog/2011/11/04/outlook-create-appointment-item/
n
nhttp://msdn.microsoft.com/en-us/library/bb612741.aspx
n
n
n
n
n
n
n
n
n