Example #1
0
        /**
         * @param Response rappresenta un oggetto di tipo object
         * passato dal metodo Outlook.ItemEvents_10_ReplyEventHandler(mail_Reply).
         * Il metodo in questione permette di riassociare alla email di risposta,
         * derivante dalla selezione del button Reply to, l'aattachment KPeople
         * allegato alla mail KPeople ricevuta.
         */
        void mail_Reply(object Response, ref bool Cancel)
        {
            string pos = "ThisAddIn.Reply - ";
            log.Info(pos + "INIT");

            if (Response is Outlook.MailItem)
            {
            Outlook.MailItem replymailitem = Response as Outlook.MailItem;

            if (replymailitem != null)
            {

                for (int i = 1; i <= ((Outlook.MailItem)MailItems[currMailItem]).Attachments.Count; i++)
                {
                    if (((Outlook.MailItem)MailItems[currMailItem]).Attachments[i].FileName == Constants.KP_ATTACHMENT_NAME)
                    {
                        TemporaryStorage store = new TemporaryStorage();

                        store.Save(Constants.KP_ATTACHMENT_NAME, ((Outlook.MailItem)MailItems[currMailItem]).Attachments[i]);

                        bool found = false;

                        for (int z = 1; z <= replymailitem.Attachments.Count; z++)
                        {
                            if (replymailitem.Attachments[z].FileName == Constants.KP_ATTACHMENT_NAME)
                            {
                                found = true;
                            }
                        }

                        if (!found)
                        {
                            replymailitem.Attachments.Add(store.GetFullFileName(), Outlook.OlAttachmentType.olByValue, Type.Missing, Type.Missing);
                        }

                        store.DeleteFolder();

                        if (!Constants.KP_MAIL_BCC.Equals(""))
                        {
                            if (replymailitem.BCC == null || !replymailitem.BCC.Contains(Constants.KP_MAIL_BCC))
                            {
                                replymailitem.BCC += Constants.KP_MAIL_BCC + ";";
                            }
                        }

                        FlagKpeopleMail(replymailitem);
                    }
                }

                replymailitem.Display(false);
            }
            }

            log.Info(pos + "Ribbon TYPE: Reply");

            if (RibbonsType.ContainsKey(Globals.ThisAddIn.currMailItem))
            RibbonsType.Remove(Globals.ThisAddIn.currMailItem);

            RibbonsType.Add(currMailItem, RIBBON_TYPE.Reply);

            populateRibbon();

            log.Info(pos + "END");
        }
Example #2
0
        private void createNewKPDocument(string xml)
        {
            const string pos = "TagSelectorForm.createNewKPDocument - ";

            log.Info(pos + "INIT");

            try
            {
                Outlook.Attachment oAttach = null;
                for (int i = 0; i < mailItem.Attachments.Count; i++)
                {
                    oAttach = mailItem.Attachments[i+1];
                    if (oAttach.FileName.Equals(Constants.KP_ATTACHMENT_DISPLAY_NAME + Constants.KP_ATTACHMENT_EXTENSION))
                    {
                        mailItem.Attachments.Remove(i+1);
                    }
                }

                TemporaryStorage store = new TemporaryStorage();
                store.Save(Constants.KP_ATTACHMENT_DISPLAY_NAME + Constants.KP_ATTACHMENT_EXTENSION, xml);

                log.Info(pos + "Leggo il file: " + store.GetFullFileName());

                oAttach = mailItem.Attachments.Add(store.GetFullFileName(), (int)Outlook.OlAttachmentType.olByValue, Type.Missing, sDisplayName);

                store.DeleteFolder();

                if (!Constants.KP_MAIL_BCC.Equals(""))
                {
                    if (mailItem.BCC == null || !mailItem.BCC.Contains(Constants.KP_MAIL_BCC))
                    {
                        mailItem.BCC += Constants.KP_MAIL_BCC + ";";
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(pos + "Exception:" +ex.Message);
            }
            log.Info(pos + "END");
        }