예제 #1
0
 public void OnMyButtonClick(Office.IRibbonControl control)
 {
     if (control.Context is Microsoft.Office.Interop.Outlook.Selection)
     {
         Microsoft.Office.Interop.Outlook.Selection   sel = control.Context as Microsoft.Office.Interop.Outlook.Selection;
         Microsoft.Office.Interop.Outlook.ContactItem cnt = sel[1];
         System.Diagnostics.Process.Start(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "CallMyPhone", "CallMyPhone.exe"), "\"" + control.Tag + "\"" + " \"" + cnt.FullName.ToString() + "\"");
     }
 }
예제 #2
0
        public void QuoteCommandClick(IRibbonControl e)
        {
            var app = Globals.ThisAddIn.Application;

            if (app == null)
            {
                return;
            }

            var inspector = app.ActiveInspector();
            var explorer  = app.ActiveExplorer();

            if (inspector == null)
            {
                return;
            }

            if (inspector.CurrentItem != null)
            {
                MailItem mailItem = inspector.CurrentItem;
                if (mailItem.BodyFormat == OlBodyFormat.olFormatHTML)
                {
                    if (inspector.EditorType == OlEditorType.olEditorHTML)
                    {
                        var editor = inspector.HTMLEditor;
                    }
                    else if (inspector.EditorType == OlEditorType.olEditorWord)
                    {
                        Microsoft.Office.Interop.Outlook.Selection oSel = explorer.Selection;

                        List <string> rawQuotes = new List <string>();

                        string author = "Кто-то";

                        for (int i = 1; i <= oSel.Count; i++)
                        {
                            var       oItem          = oSel[i];
                            MailItem  oMail          = (MailItem)oItem;
                            Inspector localInspector = oMail.GetInspector;
                            Microsoft.Office.Interop.Word.Document document =
                                (Microsoft.Office.Interop.Word.Document)inspector.WordEditor;
                            string quoteText = document.Application.Selection.Text;

                            List <ParserDescriptor> parserDescriptors = new List <ParserDescriptor>();
                            parserDescriptors.Add(new ParserDescriptor("From", "Sent"));
                            parserDescriptors.Add(new ParserDescriptor("От", "Отправлено:"));

                            foreach (var pd in parserDescriptors)
                            {
                                Object findText = pd.SearchKey;
                                Object missing  = Type.Missing;

                                var range = document.Range(document.Content.Start, document.Application.Selection.Range.Start);
                                if (range.Find.Execute(
                                        ref findText, ref missing, ref missing, true, ref missing,
                                        ref missing, false, ref missing, ref missing, ref missing,
                                        ref missing, ref missing, ref missing, ref missing, ref missing))
                                {
                                    pd.Result = document.Range(range.Start, range.End);
                                }
                            }

                            var optimalParser = parserDescriptors.OrderByDescending(pd => pd.Result == null ? 0 : pd.Result.Start).FirstOrDefault();
                            if (optimalParser != null)
                            {
                                string parsedAuthor = optimalParser.ParseSender(document);
                                if (!String.IsNullOrWhiteSpace(parsedAuthor))
                                {
                                    author = parsedAuthor;
                                }
                            }

                            rawQuotes.Add(quoteText);
                        }

                        string styledQuote = "";

                        foreach (var rawQuote in rawQuotes)
                        {
                            styledQuote += Properties.Resources.QuoteTemplate
                                           .Replace("[%QUOTE_ID%]", Guid.NewGuid().ToString().Replace("-", ""))
                                           .Replace("[%QUOTE_AUTHOR%]", author)
                                           .Replace("[%QUOTE_TEXT%]", rawQuote);
                        }

                        mailItem.HTMLBody = QuoteInsert(styledQuote, mailItem.HTMLBody);
                    }
                }
            }
        }
예제 #3
0
        public string CallbackGetContent(Office.IRibbonControl control)
        {
            StringBuilder xmlString = new StringBuilder(@"<menu xmlns=""http://schemas.microsoft.com/office/2009/07/customui"" >");

            if (control.Context is Microsoft.Office.Interop.Outlook.Selection)

            {
                Microsoft.Office.Interop.Outlook.Selection selection = control.Context as Microsoft.Office.Interop.Outlook.Selection;
                if (selection.Count == 1)

                {
                    Microsoft.Office.Interop.Outlook.ContactItem contact1 = selection[1] as Microsoft.Office.Interop.Outlook.ContactItem;

                    if (contact1.MobileTelephoneNumber != null)
                    {
                        xmlString.Append(@"<button id='MobileTelephoneNumber' tag='" + contact1.MobileTelephoneNumber + "' label='Мобильный: " + contact1.MobileTelephoneNumber + "' onAction='OnMyButtonClick'/>");
                    }
                    if (contact1.BusinessTelephoneNumber != null)
                    {
                        xmlString.Append(@"<button id='BusinessTelephoneNumber' tag='" + contact1.BusinessTelephoneNumber + "' label='Рабочий: " + contact1.BusinessTelephoneNumber + "' onAction='OnMyButtonClick'/>");
                    }
                    if (contact1.AssistantTelephoneNumber != null)
                    {
                        xmlString.Append(@"<button id='AssistantTelephoneNumber' tag='" + contact1.AssistantTelephoneNumber + "' label='Помощник: " + contact1.AssistantTelephoneNumber + "' onAction='OnMyButtonClick'/>");
                    }
                    if (contact1.Business2TelephoneNumber != null)
                    {
                        xmlString.Append(@"<button id='Business2TelephoneNumber' tag='" + contact1.Business2TelephoneNumber + "' label='Рабочий 2: " + contact1.Business2TelephoneNumber + "' onAction='OnMyButtonClick'/>");
                    }
                    if (contact1.BusinessFaxNumber != null)
                    {
                        xmlString.Append(@"<button id='BusinessFaxNumber' tag='" + contact1.BusinessFaxNumber + "' label='Факс (рабочий): " + contact1.BusinessFaxNumber + "' onAction='OnMyButtonClick'/>");
                    }
                    if (contact1.CallbackTelephoneNumber != null)
                    {
                        xmlString.Append(@"<button id='CallbackTelephoneNumber' tag='" + contact1.CallbackTelephoneNumber + "' label='Ответ на звонок: " + contact1.CallbackTelephoneNumber + "' onAction='OnMyButtonClick'/>");
                    }
                    if (contact1.CarTelephoneNumber != null)
                    {
                        xmlString.Append(@"<button id='CarTelephoneNumber' tag='" + contact1.CarTelephoneNumber + "' label='Автомобиль: " + contact1.CarTelephoneNumber + "' onAction='OnMyButtonClick'/>");
                    }
                    if (contact1.CompanyMainTelephoneNumber != null)
                    {
                        xmlString.Append(@"<button id='CompanyMainTelephoneNumber' tag='" + contact1.CompanyMainTelephoneNumber + "' label='Организация: " + contact1.CompanyMainTelephoneNumber + "' onAction='OnMyButtonClick'/>");
                    }
                    if (contact1.Home2TelephoneNumber != null)
                    {
                        xmlString.Append(@"<button id='Home2TelephoneNumber' tag='" + contact1.Home2TelephoneNumber + "' label='Домашний 2: " + contact1.Home2TelephoneNumber + "' onAction='OnMyButtonClick'/>");
                    }
                    if (contact1.HomeFaxNumber != null)
                    {
                        xmlString.Append(@"<button id='HomeFaxNumber' tag='" + contact1.HomeFaxNumber + "' label='Факс дом.: " + contact1.HomeFaxNumber + "' onAction='OnMyButtonClick'/>");
                    }
                    if (contact1.HomeTelephoneNumber != null)
                    {
                        xmlString.Append(@"<button id='HomeTelephoneNumber' tag='" + contact1.HomeTelephoneNumber + "' label='Домашний: " + contact1.HomeTelephoneNumber + "' onAction='OnMyButtonClick'/>");
                    }
                    if (contact1.OtherTelephoneNumber != null)
                    {
                        xmlString.Append(@"<button id='OtherTelephoneNumber' tag='" + contact1.OtherTelephoneNumber + "' label='Другой: " + contact1.OtherTelephoneNumber + "' onAction='OnMyButtonClick'/>");
                    }
                    if (contact1.RadioTelephoneNumber != null)
                    {
                        xmlString.Append(@"<button id='RadioTelephoneNumber' tag='" + contact1.RadioTelephoneNumber + "' label='Радио: " + contact1.RadioTelephoneNumber + "' onAction='OnMyButtonClick'/>");
                    }
                }
            }

            xmlString.Append(@"</menu>");

            return(xmlString.ToString());
        }