Example #1
0
        // Return the url of the 'View article' link that appears in the headline of the RSS item.
        public static string ParseUrl(Outlook.PostItem item)
        {
            const string lookUpText = "HYPERLINK";
            const string articleStr = "View article";
            string       body       = item.Body;

            int index = body.IndexOf(lookUpText, 0, body.Length);
            int end   = 0;

            // Look through body for 'HYPERLINKS' and narrow down to 'View article...' link.
            while (true)
            {
                end = body.IndexOf(articleStr, index, body.Length - index);
                int nextIndex = body.IndexOf(lookUpText, index + 1, body.Length - (index + 1));

                if (nextIndex > index && nextIndex < end)
                {
                    index = nextIndex;
                }
                else
                {
                    break;
                }
            }
            // Get the Link to the article.
            string url = body.Substring(index + lookUpText.Length + 1, end - index - (lookUpText.Length + 1));

            url = url.Trim('"');

            return(url);
        }
Example #2
0
        // 返回出现在 RSS 项的标题中的“View article”链接的 URL。
        public static string ParseUrl(Outlook.PostItem item)
        {
            const string lookUpText = "HYPERLINK";
            const string articleStr = "View article";
            string       body       = item.Body;

            int index = body.IndexOf(lookUpText, 0, body.Length);
            int end   = 0;

            // 在正文中查找“HYPERLINKS”并将范围缩小到“View article...”链接。
            while (true)
            {
                end = body.IndexOf(articleStr, index, body.Length - index);
                int nextIndex = body.IndexOf(lookUpText, index + 1, body.Length - (index + 1));

                if (nextIndex > index && nextIndex < end)
                {
                    index = nextIndex;
                }
                else
                {
                    break;
                }
            }
            // 获取文章的链接。
            string url = body.Substring(index + lookUpText.Length + 1, end - index - (lookUpText.Length + 1));

            url = url.Trim('"');

            return(url);
        }
Example #3
0
 protected override void Close()
 {
     Globals.ThisAddIn.EventTrackerForm.AddLog("Inspector_Close (PostItem)");
     Item = null;
     GC.Collect();
     GC.WaitForPendingFinalizers();
 }
Example #4
0
        /// <summary>
        /// Displays the selected email
        /// </summary>
        /// <param name="pintIndex"></param>
        private void ShowItem(int pintIndex)
        {
            if (pintIndex >= Items.Count)
            {
                return;
            }
            string strSubject = string.Empty;
            string strBody    = string.Empty;

            if (Items[pintIndex] is Outlook.MailItem)
            {
                // Get the item
                Outlook.MailItem objItem = (Outlook.MailItem)Items[pintIndex];

                // Extract info
                strSubject = objItem.Subject;
                strBody    = objItem.Body;
            }
            else if (Items[pintIndex] is Outlook.PostItem)
            {
                Outlook.PostItem objItem = (Outlook.PostItem)Items[pintIndex];

                // Extract info
                strSubject = objItem.Subject;
                strBody    = objItem.Body;
            }

            // Display info
            this.Text                    = string.Format(_strDialogTitle, strSubject);
            this.txtBody.Text            = strBody;
            this.txtBody.SelectionStart  = 0;
            this.txtBody.SelectionLength = 0;
        }
Example #5
0
        // Occurs before the form region is displayed.
        // Use this.OutlookItem to get a reference to the current Outlook item.
        // Use this.OutlookFormRegion to get a reference to the form region.
        private void RssRegion_FormRegionShowing(object sender, System.EventArgs e)
        {
            this.RssRegionSplitContainer.Panel2Collapsed = true;

            Outlook.PostItem rssItem = (Outlook.PostItem) this.OutlookItem;

            this.webBrowserRss.Navigate(Helper.ParseUrl(rssItem));
        }
Example #6
0
        protected internal FollowUpPostItem(Outlook.PostItem t)
        {
            if (t == null)
            {
                throw new ArgumentException("PostItem is null");
            }

            _item = t;
        }
Example #7
0
        /// <summary>
        /// Method is called when the Wrapper has been initialized
        /// </summary>
        protected override void Initialize()
        {
            // Get the Item of the current Inspector
            Item = (Outlook.PostItem)Inspector.CurrentItem;

            // Register for the Item events
            Item.Open  += new Outlook.ItemEvents_10_OpenEventHandler(Item_Open);
            Item.Write += new Outlook.ItemEvents_10_WriteEventHandler(Item_Write);
        }
Example #8
0
        /// <summary>
        /// The Close Method is called when the Inspector has been closed.
        /// Do your cleanup tasks here.
        /// The UI is gone, can't access it here.
        /// </summary>
        protected override void Close()
        {
            // unregister events
            Item.Write -= new Outlook.ItemEvents_10_WriteEventHandler(Item_Write);
            Item.Open  -= new Outlook.ItemEvents_10_OpenEventHandler(Item_Open);

            // required, just stting to NULL may keep a reference in memory of the Garbage Collector.
            Item = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Example #9
0
        // Clicking on 'SearchSimilarTopicsbutton' will open 'webBrowserSearch' in a Separate Pane.
        private void searchSimilarTopicsButton_Click(object sender, EventArgs e)
        {
            Outlook.PostItem rssItem = (Outlook.PostItem) this.OutlookItem;

            this.searchSimilarTopicsButton.Visible = false;

            this.RssRegionSplitContainer.Panel2Collapsed = false;

            // Search for the matching titles by placing title in "".
            this.webBrowserSearch.Navigate(string.Concat("http://www.bing.com/search?q=\"", rssItem.Subject, "\""));

            this.RssRegionSplitContainer.SplitterDistance = (this.OutlookFormRegion.Inspector.Width / 2);

            this.searchWindowProgressBar.Visible = true;
        }
Example #10
0
 private static FollowUpItem GetFollowUpItemInt(Outlook.PostItem p)
 {
     return(new FollowUpPostItem(p));
 }
Example #11
0
 /// <summary>
 /// Delete all mail items in folder
 /// </summary>
 /// <param name="mapiFolder">The folder need to delete all mails</param>
 public static void DeleteAllItemInMAPIFolder(Outlook.MAPIFolder mapiFolder)
 {
     if (mapiFolder.Items != null)
     {
         int count = mapiFolder.Items.Count;
         if (count == 0)
         {
             return;
         }
         else
         {
             try
             {
                 do
                 {
                     if (mapiFolder.Items.GetFirst() is Outlook.MailItem)
                     {
                         Outlook.MailItem outlookMail = (Outlook.MailItem)mapiFolder.Items.GetFirst();
                         if (outlookMail != null)
                         {
                             outlookMail.Delete();
                             Marshal.ReleaseComObject(outlookMail);
                             count--;
                         }
                     }
                     else if (mapiFolder.Items.GetFirst() is Outlook.PostItem)
                     {
                         Outlook.PostItem outlookPost = (Outlook.PostItem)mapiFolder.Items.GetFirst();
                         if (outlookPost != null)
                         {
                             outlookPost.Delete();
                             Marshal.ReleaseComObject(outlookPost);
                             count--;
                         }
                     }
                     else if (mapiFolder.Items.GetFirst() is Outlook.MeetingItem)
                     {
                         Outlook.MeetingItem outlookMeeting = (Outlook.MeetingItem)mapiFolder.Items.GetFirst();
                         if (outlookMeeting != null)
                         {
                             outlookMeeting.Delete();
                             Marshal.ReleaseComObject(outlookMeeting);
                             count--;
                         }
                     }
                     else if (mapiFolder.Items.GetFirst() is Outlook.AppointmentItem)
                     {
                         Outlook.AppointmentItem outlookAppointment = (Outlook.AppointmentItem)mapiFolder.Items.GetFirst();
                         if (outlookAppointment != null)
                         {
                             outlookAppointment.Delete();
                             Marshal.ReleaseComObject(outlookAppointment);
                             count--;
                         }
                     }
                 }while (count > 0);
             }
             catch (Exception e)
             {
                 throw new Exception(e.Message);
             }
         }
     }
 }
Example #12
0
 protected override void Initialize()
 {
     Item = (Outlook.PostItem)Inspector.CurrentItem;
 }
Example #13
0
        // 在显示窗体区域之前发生。
        // 使用 this.OutlookItem 获取对当前 Outlook 项的引用。
        // 使用 this.OutlookFormRegion 获取对窗体区域的引用。
        private void RssPane_FormRegionShowing(object sender, System.EventArgs e)
        {
            Outlook.PostItem rssItem = (Outlook.PostItem) this.OutlookItem;

            this.webBrowserRss.Navigate(Helper.ParseUrl(rssItem));
        }