public void DoNag(Object item)
        {
            Outlook.MailItem msg = (Outlook.MailItem)item;
            // Blah.  Creating a new mail from scratch is a problem, because if the user then replies to the AutoLottie, it doesn't
            // hook up.  Creating a new mail using 'reply' is impossible because the one in the Lottie folder is still only a draft.
            // Going to try looking up the e-mail in regular sent-mail... If this works, then longer term, the approach should be
            // changed so that the real e-mail gets stored in the Lottie folder, introducing the requirement that mail goes to sent-mail.
            // Also, we can trigger the Lottie actions with a watch on sent-mail, which has a lot of other benefits.
            Outlook.MAPIFolder sentmail = outlookNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail);
            // TODO FALLS OVER WITH PUNCTUATION (like ') in the SUBJECT LINE
            String sFilter = "[Subject] = '" + msg.Subject + "'";

            Outlook.Items sublist        = sentmail.Items.Restrict(sFilter);
            DateTime      latestSentTime = new DateTime(0);

            Outlook.MailItem bestFitMail = null;
            Outlook.MailItem messageIt   = (Outlook.MailItem)sublist.GetFirst();
            while (messageIt != null)
            {
                if ((((Outlook.MailItem)messageIt).ConversationID == msg.ConversationID) && (((Outlook.MailItem)messageIt).SentOn.CompareTo(latestSentTime) == 1))
                {
                    bestFitMail    = (Outlook.MailItem)messageIt;
                    latestSentTime = ((Outlook.MailItem)messageIt).SentOn;
                }
                messageIt = (Outlook.MailItem)sublist.GetNext();
            }

            if (bestFitMail != null)
            {
                Outlook.MailItem eMail = bestFitMail.ReplyAll();
                //(Outlook.MailItem)this.Application.CreateItem(Outlook.OlItemType.olMailItem);
                // if you change the subject, Conversation ID gets changed :-(
                //   eMail.Subject = "[AutoLottie] " + bestFitMail.Subject;
                //          eMail.To = msg.To;
                eMail.CC   = bestFitMail.SenderEmailAddress;
                eMail.Body = "As far as my Outlook client can tell, you have not yet responded " +
                             "to the message below.  Could you do so now, please?\n\n " +
                             "Thanks! \n\n" +
                             "************************************************************\n\n\n" + bestFitMail.Body;
                eMail.Importance = Outlook.OlImportance.olImportanceNormal;

                Outlook.UserProperty lottieStartThreadProperty = eMail.UserProperties.Add(AutoLottieAddIn.LottieNoCancelProperty, Outlook.OlUserPropertyType.olText);
                lottieStartThreadProperty.Value = "True";

                ((Outlook._MailItem)eMail).Send();
            }
            // Not sure what to do here:
            // 1) Set the AutoLottie property so that they get nagged again in the same length of time?
            // 2) Remove the AutoLottie?
            // 3) Something random - they get nagged in double the time.  I think I'll do that. :-)
            TimeSpan expiryTimeFromSent;

            TimeSpan.TryParse(msg.UserProperties[LottieDurationProperty].Value.ToString(), out expiryTimeFromSent);
            TimeSpan newExpiryTime = new TimeSpan(2 * expiryTimeFromSent.Days, 2 * expiryTimeFromSent.Hours, 2 * expiryTimeFromSent.Minutes, 0);

            UpdateTimerForMessage(msg, newExpiryTime);
        }
Exemple #2
0
        private void Comment()
        {
            Outlook.MailItem mail    = explorer.Selection[1];
            string           comment = mail.Body.Substring(0, mail.Body.IndexOf("From:", StringComparison.CurrentCulture));
            int    start             = mail.Body.IndexOf("Ticket", StringComparison.CurrentCultureIgnoreCase);
            string ticket            = mail.Body.Substring(start, 12);
            string nticket           = ticket.Substring(6, 6).Trim();

            Outlook.MailItem resp = mail.ReplyAll();
            string           text = cortaComment(resp.Body);
            string           json = "{\"body\":\"" + text + "\"}";

            SendRequest(json, "http://xxxx.xxxxx.net/rest/api/2/issue/SC-" + nticket + "/comment");
            string texto = "Seu comentario foi adicionado ao ticket <b>" + nticket + "</b> para o analista responsável verificar e te dar um retorno sobre o proceso.";

            resp.HTMLBody = geraHTML(resp.HTMLBody, texto);
            resp.Display();
        }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked == true)
            {
                if (textBox1.Text == "")
                {
                    MessageBox.Show("Campo summary obrigatório");
                    return;
                }

                Outlook.MailItem mail = explorer.Selection[1];
                Outlook.MailItem resp = mail.ReplyAll();

                string ReqBy = RequestBy(mail);

                string text = cortaBody(resp.Body);

                string description = text;
                string summary     = textBox1.Text;
                string Analista    = selectAssigne(ReqBy);
                if (Analista == "atd")
                {
                    Analista = "lpicazio";
                }
                string Category     = "Incident";
                string SubCategory  = "SW - Third Party Systems";
                string SubCategory2 = "Others";
                string SubCategory3 = "N/A";
                string SubCategory4 = "N/A";


                string json    = criaJson(description, summary, Category, ReqBy, Analista, SubCategory, SubCategory2, SubCategory3, SubCategory4);
                string url     = "http://xxxx.xxxx.net/rest/api/2/issue";
                string respReq = SendRequest(json, url);

                string nTicket = respReq.Substring(respReq.IndexOf("SC-"), 8); // Tira o SC do ticket
                string sc      = "SC-";
                nTicket = nTicket.TrimStart(sc.ToCharArray());

                string texto = "O ticket <b>" + nTicket + "</b> foi aberto para um de nossos analistas verificar.";
                resp.HTMLBody = geraHTML(resp.HTMLBody, texto);
                resp.Display();
            }
            if (radioButton2.Checked == true)
            {
                Outlook.MailItem mail        = explorer.Selection[1]; //sim
                string           summary     = "Shared Drive - Acesso";
                Outlook.MailItem resp        = mail.ReplyAll();       //sim
                string           description = cortaBody(resp.Body);

                string reqBy = RequestBy(mail);

                string Analista = selectAssigne(reqBy);

                string Category     = "Access Request";
                string SubCategory  = "Shared Drive";
                string SubCategory2 = "N/A";
                string SubCategory3 = "N/A";
                string SubCategory4 = "N/A";

                string json = criaJson(description, summary, Category, reqBy, Analista, SubCategory, SubCategory2, SubCategory3, SubCategory4);
                string url  = "http://xxxx.xxxx.net/rest/api/2/issue";

                string respReq = SendRequest(json, url);
                string nTicket = respReq.Substring(respReq.IndexOf("SC-"), 8);
                string sc      = "SC-";
                nTicket = nTicket.TrimStart(sc.ToCharArray());
                string texto = "O ticket <b>" + nTicket + " </b>foi aberto para um de nossos analistas verificar o acesso, assim que aprovado.<b>LEMBRAR DE COLOCAR APROVADOR</b>";
                resp.HTMLBody = geraHTML(resp.HTMLBody, texto);
                resp.Display();
            }
            if (radioButton3.Checked == true)
            {
                Outlook.MailItem mail        = explorer.Selection[1];
                string           summary     = "File Record  - Gravação";
                Outlook.MailItem resp        = mail.ReplyAll();
                string           description = cortaBody(resp.Body);

                string name = RequestBy(mail);

                string Analista = selectAssigne(name);

                string Category     = "RFS (Request for Service)";
                string SubCategory  = "File Record";
                string SubCategory2 = "File Outing - Other";
                string SubCategory3 = "N/A";
                string SubCategory4 = "N/A";

                string json    = criaJson(description, summary, Category, name, Analista, SubCategory, SubCategory2, SubCategory3, SubCategory4);
                string url     = "http://xxxx.xxxx.net/rest/api/2/issue";
                string respReq = SendRequest(json, url);
                string nTicket = respReq.Substring(respReq.IndexOf("SC-"), 8);
                string sc      = "SC-";
                nTicket = nTicket.TrimStart(sc.ToCharArray());
                string texto = "O ticket<b> " + nTicket + "</b> foi aberto para um de nossos analistas verificar a gravação.";
                resp.HTMLBody = geraHTML(resp.HTMLBody, texto);
                resp.Display();
            }
            if (radioButton4.Checked == true)
            {
                Comment();
            }
            if (radioButton5.Checked == true)
            {
                Outlook.MailItem mail    = explorer.Selection[1];
                string           comment = mail.Body.Substring(0, mail.Body.IndexOf("From:", StringComparison.CurrentCulture));
                int              start   = mail.Body.IndexOf("Ticket", StringComparison.CurrentCultureIgnoreCase);
                string           ticket  = mail.Body.Substring(start, 12);
                string           nticket = ticket.Substring(6, 6).Trim();
                Outlook.MailItem resp    = mail.ReplyAll();
                string           text    = resp.Body.Replace("\"", "");
                text = text.Replace("\r", "");
                text = text.Replace("\\", "");
                text = text.Replace("\n", "\\n");
                text = text.Replace("\'", "");
                text = text.Replace("\t", "");
                text = text.Substring(text.IndexOf("From"));
                text = text.Substring(0, text.IndexOf("From", 6));
                string json = "{\"update\":{\"comment\":[{\"add\":{\"body\":\"" + text + "\"}}]},\"transition\":{\"id\":\"31\"}}";
                SendRequest(json, "http://xxx.xxxx.net/rest/api/2/issue/SC-" + nticket + "/transitions");
                string texto = "Ticket <b>" + nticket + "</b> atualizado com a aprovação.";
                resp.HTMLBody = geraHTML(resp.HTMLBody, texto);
                resp.Display();
            }
            textBox1.Clear();
        }