public MonitorPath() { this.m_OutlookApp = new Microsoft.Office.Interop.Outlook.Application(); this.m_OutlookNameSpace = (Microsoft.Office.Interop.Outlook._NameSpace) this.m_OutlookApp.GetNamespace("MAPI"); this.m_MAPIFolder = this.m_OutlookNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox); this.m_Explorer = this.m_MAPIFolder.GetExplorer(false); this.m_OutlookNameSpace.Logon(System.Reflection.Missing.Value, System.Reflection.Missing.Value, false, true); this.m_PageQueue = new Queue <System.Windows.Controls.UserControl>(); this.m_MonitorPageWindow = new MonitorPageWindow(); }
public void HandleReplyWithTemplate(JiraTemplate jiraTemplate) { if (dataModel.JiraEmail == null || dataModel.JiraEmail.Length < 1) { MessageBox.Show("Invalid Jira Email.\nPlease update email address in Jira Tab.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (jiraTemplate == null) { // fallback to default jiraTemplate = dataModel.DefaultTemplate; } try { Outlook._Explorer exp = Globals.ThisAddIn.Application.ActiveExplorer(); if (exp != null && exp.Selection != null && exp.Selection.Count > 0) { foreach (Object item in exp.Selection) { if (item is Outlook._MailItem) { Outlook._MailItem mailItem = (item as Outlook._MailItem); Outlook._MailItem reply = mailItem.ReplyAll(); AddTemplateDataToMailItem(reply, jiraTemplate); reply.Display(); } } } } catch (Exception Ex) { // To see this exception: Click on the email folders tree's top node i.e. the one which shows like a startup page // and contains Calendar information, tasks and messages overview. After that from ribbon click on the reply button. // http://stackoverflow.com/questions/17211827/how-to-check-if-a-vsto-outlook-explorer-object-has-been-closed // Ex.Message = "The Explorer has been closed and cannot be used for further operations. Review your code and restart Outlook." // Outlook gives valid explorer but selection paramter generates exception. //MessageBox.Show(Ex.Message + "\n" + Ex.StackTrace, "Error!!!"); RegistryOperation.CreateBinaryKeyValue(RegistryOperation.szAppRegPathGeneral, RegistryOperation.szKeyNameLastError, Ex.Message.ToString() + "\n" + Ex.StackTrace.ToString()); } }
public MonitorPath() { this.m_OutlookApp = new Microsoft.Office.Interop.Outlook.Application(); this.m_OutlookNameSpace = (Microsoft.Office.Interop.Outlook._NameSpace)this.m_OutlookApp.GetNamespace("MAPI"); this.m_MAPIFolder = this.m_OutlookNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox); this.m_Explorer = this.m_MAPIFolder.GetExplorer(false); this.m_OutlookNameSpace.Logon(System.Reflection.Missing.Value, System.Reflection.Missing.Value, false, true); this.m_LastReportDistributionHeartBeat = DateTime.Now.AddMinutes(-5); ISubscriber subscriber = Business.RedisConnection.Instance.GetSubscriber(); subscriber.Subscribe("ReportDistributionHeartBeat", (channel, message) => { this.m_LastReportDistributionHeartBeat = DateTime.Now; }); this.m_PageQueue = new Queue<System.Windows.Controls.UserControl>(); this.m_MonitorPageWindow = new MonitorPageWindow(); }