Beispiel #1
0
 internal void NewReply(string language)
 {
     // Create new reply
     templatePath   = OBPGlobals.templatePathFromLanguage(language);
     consultantName = OBPGlobals.consultantName;
     fromAddress    = OBPGlobals.fromAddressFromLanguage(language);
     bccAddress     = OBPGlobals.salesForceTrackingAddress;
     Outlook.MailItem newReply;
     Outlook.Folder   draftFolder;
     draftFolder = Globals.ThisAddIn.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDrafts) as Outlook.Folder;
     if (!File.Exists(templatePath))
     {
         throw new FileNotFoundException("Unable to open the email template. " +
                                         "Please verify that the correct email template path is specified in Settings. " +
                                         "Default path:\n" +
                                         @"X:\OBP Team\Team Folders\Tech PreSales\Outlook Templates for SFDC Macro\");
     }
     newReply         = Globals.ThisAddIn.Application.CreateItemFromTemplate(templatePath, draftFolder) as Outlook.MailItem;
     newReply.Subject = "Case ID " + idNumber + " - " + questionSubject + " " + refCode;
     newReply.To      = toAddress;
     newReply.BCC     = bccAddress;
     //newReply.CC = ccAddress;
     newReply.SentOnBehalfOfName = fromAddress;
     newReply.HTMLBody           = newReply.HTMLBody.Replace("[CALLER]", customerName);
     newReply.HTMLBody           = newReply.HTMLBody.Replace("[CONSULTANT]", consultantName);
     newReply.HTMLBody           = newReply.HTMLBody.Replace("[QUESTION]", questionContent);
     // Luis
     newReply.HTMLBody = newReply.HTMLBody.Replace("%5bCASE_ID%5d", idNumber);
     replyEmail        = newReply;
 }
Beispiel #2
0
        internal void FindOriginal()
        {
            string subjectToFind = firstQuestion ? questionSubject : questionSubjectFollowUp;
            // Check language mailboxes
            List <string> selectedLanguagesPlusNone = new List <string>(OBPGlobals.selectedLanguages);

            selectedLanguagesPlusNone.Add("none");
            foreach (string language in selectedLanguagesPlusNone) // iterate over mailboxes
            {
                string        mailBoxName     = OBPGlobals.mailBoxFromLanguage(language);
                Outlook.Items mailFolderItems = GetFolder(mailBoxName).Items;
                mailFolderItems.Sort("[ReceivedTime]", true);
                foreach (object o in mailFolderItems) // iterate over items in mailbox
                {
                    if (o is Outlook.MailItem)
                    {
                        Outlook.MailItem tempMail    = (Outlook.MailItem)o;
                        string           tempSubject = tempMail.Subject;
                        if (subjectToFind.Equals(tempSubject)) // check subject
                        {
                            string tempEmailAddress = GetSenderSMTPAddress(tempMail);
                            if (toAddress.ToLower() == tempEmailAddress.ToLower()) // check sender
                            {
                                bool match = true;
                                if (!firstQuestion) // if reply, check date
                                {
                                    if (!tempMail.SentOn.Date.Equals(sentDateFollowUp.Date))
                                    {
                                        match = false;
                                    }
                                }
                                if (match)
                                {
                                    originalEmail = tempMail;
                                    return;
                                }
                            }
                        }
                    }
                }
            }
            string errorMessage = "Email was not found when searching the following mailboxes:";

            foreach (string l in selectedLanguagesPlusNone)
            {
                errorMessage += Environment.NewLine + OBPGlobals.mailBoxFromLanguage(l);
            }
            throw new FileNotFoundException(errorMessage);
        }