Beispiel #1
0
        public void OnShowHeaderClick(IRibbonControl control)
        {
            MailItem selObject;

            if (control.Context is Inspector)
            {
                var item = control.Context as Inspector;
                selObject = item.CurrentItem as MailItem;
            }
            else if (control.Context is Explorer)
            {
                Explorer expl = control.Context as Explorer;
                selObject = expl.Application.ActiveExplorer().Selection[1] as MailItem;
            }
            else
            {
                return;
            }

            // Show the Info
            VMInfoScreen.ShowHeader(scoring.getSummary(selObject));
        }
Beispiel #2
0
        //private void EnumerateFolders(Folder folder)
        //{
        //    foreach (Folder childFolder in folder.Folders)
        //    {
        //        try
        //        {
        //            // iterate through mails in this folder
        //            Items mails = childFolder.Items;
        //            foreach (object mail in childFolder.Items)
        //            {
        //                if (mail is MailItem)
        //                {
        //                    var mailItem = mail as MailItem;
        //                    var senderName = mailItem.SenderName;
        //                    var senderEmailAddress = mailItem.SenderEmailAddress;
        //                    var senderCombo = senderName + "/" + senderEmailAddress;

        //                    if (senderEmailAddress is null)
        //                        continue;

        //                    if (DictSenderName.ContainsKey(senderName))
        //                    {
        //                        DictSenderName[senderName] = DictSenderName[senderName] + 1;
        //                    }
        //                    else
        //                    {
        //                        DictSenderName.Add(senderName, 1);
        //                    }
        //                    if (DictSenderEmail.ContainsKey(senderEmailAddress))
        //                    {
        //                        DictSenderEmail[senderEmailAddress] = DictSenderEmail[senderEmailAddress] + 1;
        //                    }
        //                    else
        //                    {
        //                        DictSenderEmail.Add(senderEmailAddress, 1);
        //                    }
        //                    if (DictSenderCombo.ContainsKey(senderCombo))
        //                    {
        //                        DictSenderCombo[senderCombo] = DictSenderCombo[senderCombo] + 1;
        //                    }
        //                    else
        //                    {
        //                        DictSenderCombo.Add(senderCombo, 1);
        //                    }
        //                }
        //            }
        //        }
        //        catch (System.Exception ex)
        //        {
        //            // throw;
        //        }
        //        // Call EnumerateFolders using childFolder.
        //        EnumerateFolders(childFolder);
        //    }
        //    // TODO: nicer user path from modelConfig
        //    string userpath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
        //    dt.Write(DictSenderName, userpath + "\\dict-sender-name.bin");
        //    dt.Write(DictSenderEmail, userpath + "\\dict-sender-email.bin");
        //    dt.Write(DictSenderCombo, userpath + "\\dict-sender-combo.bin");
        //}

        public void CurrentExplorer_Event()
        {
            MAPIFolder selectedFolder = Application.ActiveExplorer().CurrentFolder;
            string     expMessage     = ""; // "Your current folder is " + selectedFolder.Name + ".\n";
            string     itemMessage    = ""; // "Item is unknown.";

            try
            {
                if (Application.ActiveExplorer().Selection.Count > 0)
                {
                    MailItem mailItem = Application.ActiveExplorer().Selection[1] as MailItem;
                    if (mailItem != null)
                    {
                        try
                        {
                            // Show warning or close may open window
                            var scoreResult = scoring.getSummary(mailItem);
                            if (scoreResult.IsSuspicious)
                            {
                                VMInfoScreen.ShowScore(scoreResult);
                            }
                            else
                            {
                                VMInfoScreen.Close();
                            }

                            tvcntr++;
                        }
                        catch (System.Exception ex)
                        {
                            Debug.Write(ex.StackTrace);
                        }
                        // remove finalfrontier p that are already present
                        //int startpos = mailItem.HTMLBody.IndexOf("<p class=\"finalfrontier");
                        //int endpos = mailItem.HTMLBody.IndexOf("</p>");
                        //if (!startpos.Equals(-1)) mailItem.HTMLBody = mailItem.HTMLBody.Remove(startpos, endpos-startpos);
                        //mailItem.HTMLBody = "<p class=\"finalfrontier\" style=\"background-color:red\"><b>FinalFrontier</b><br/>" + itemMessage + "</p>" + mailItem.HTMLBody;


                        //mailItem.Display(false);
                    }

                    /*                    else if (selObject is Outlook.ContactItem)
                     *                  {
                     *                      Outlook.ContactItem contactItem =
                     *                          (selObject as Outlook.ContactItem);
                     *                      itemMessage = "The item is a contact." +
                     *                          " The full name is " + contactItem.Subject + ".";
                     *                      contactItem.Display(false);
                     *                  }
                     *                  else if (selObject is Outlook.AppointmentItem)
                     *                  {
                     *                      Outlook.AppointmentItem apptItem =
                     *                          (selObject as Outlook.AppointmentItem);
                     *                      itemMessage = "The item is an appointment." +
                     *                          " The subject is " + apptItem.Subject + ".";
                     *                  }
                     *                  else if (selObject is Outlook.TaskItem)
                     *                  {
                     *                      Outlook.TaskItem taskItem =
                     *                          (selObject as Outlook.TaskItem);
                     *                      itemMessage = "The item is a task. The body is "
                     + taskItem.Body + ".";
                     +                  }
                     +                  else if (selObject is Outlook.MeetingItem)
                     +                  {
                     +                      Outlook.MeetingItem meetingItem =
                     +                          (selObject as Outlook.MeetingItem);
                     +                      itemMessage = "The item is a meeting item. " +
                     +                           "The subject is " + meetingItem.Subject + ".";
                     +                  }
                     */

                    expMessage = expMessage + itemMessage;
                }
            }
            catch (System.Exception ex)
            {
                expMessage = ex.Message;
            }
            //MessageBox.Show(expMessage);
        }