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"); }
/** * @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"); }
public void Populate(KPOutlookAddIn.ThisAddIn.RIBBON_TYPE showRibbon, Outlook.MailItem mail) { log = new Logger(); currMailItem = mail; const string pos = "RibbonMailRiceved.RibbonMailRiceved_Load - "; log.Info(pos + "INIT"); string pathWorkFolder = Constants.getWorkFolder(); string attachmentName = Constants.KP_ATTACHMENT_NAME; log.Info(pos + "pathWorkFolder:" + pathWorkFolder); log.Info(pos + "attachmentName:" + attachmentName); try { if (showRibbon == ThisAddIn.RIBBON_TYPE.Read) { //Disabilito il pulsante kpeople this.button1.Enabled = false; //Leggo le informazioni dall'attachment Outlook.Attachment attach = mail.Attachments[attachmentName]; if (attach != null) { //Salvo temporaneamente il file TemporaryStorage storage = new TemporaryStorage(); XmlDocument docXml = new XmlDocument(); MetadataParser parser = new MetadataParser(); docXml.Load(storage.Save(attach)); createDinamicallyRibbonFromMetadata(parser.parserMetadataSetFromXML(docXml)); storage.DeleteFolder(); } } else if (showRibbon == ThisAddIn.RIBBON_TYPE.Reply) { //Disabilito il pulsante kpeople this.button1.Enabled = true; //Leggo le informazioni dall'attachment Outlook.Attachment attach = mail.Attachments[attachmentName]; if (attach != null) { //Salvo temporaneamente il file TemporaryStorage storage = new TemporaryStorage(); XmlDocument docXml = new XmlDocument(); MetadataParser parser = new MetadataParser(); docXml.Load(storage.Save(attach)); createDinamicallyRibbonFromMetadata(parser.parserMetadataSetFromXML(docXml)); storage.DeleteFolder(); } } else { this.button1.Enabled = true; } } catch (Exception ex) { log.Error(pos + "Ex:" + ex.ToString()); } log.Info(pos + "END"); }