1
votes

I have added Two buttons that send and copy and send and move emails from outlook to our document management system that sits in Sharepoint. I have both buttons working but the automatic spellcheck in outlook isn't invoked. Is there a way to invoke outlooks 2007 spellcheck before sending the email programmatically.

Here's a code snippet...

enter code here

void Application_ItemContextMenuDisplay(Microsoft.Office.Core.CommandBar CommandBar, Microsoft.Office.Interop.Outlook.Selection Selection)
    {
      try
        {
        CommandBar.Controls[1].BeginGroup = true; // add seperator before first menu
            if (Selection.Count == 1)
            {
                _mailItem = Selection[1] as Outlook.MailItem;

                if (_mailItem != null)
                {
          Office.CommandBarButton cmdButtonCopy = (Office.CommandBarButton)CommandBar.Controls.Add(Office.MsoControlType.msoControlButton, 1, Missing.Value, 1, Missing.Value);
                    cmdButtonCopy.Caption = "&Copy to DMS";
                    cmdButtonCopy.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(cmdButtonCopy_Click);

                    Office.CommandBarButton cmdButtonMove = (Office.CommandBarButton)CommandBar.Controls.Add(Office.MsoControlType.msoControlButton, Missing.Value, Missing.Value, 2, Missing.Value);
                    cmdButtonMove.Caption = "&Move to DMS";
                    cmdButtonMove.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(cmdButtonMove_Click);                           


                }
            }
        }
        catch (Exception ex)
        {
            ExceptionService.Instance.Handle(ex.Message, ex);
        }
    }

    void cmdButtonCopy_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault)
    {
        try
        { 

           **// would  like to invoke spell check here......**
           Outlook.
            Utils.SendToDMS(_mailItem, false);





        }
        catch (Exception ex)
        {
            ExceptionService.Instance.Handle(ex.Message, ex);
        }
    }
2

2 Answers

0
votes

The method that I found that works is to programmatically press Alt+S, which is the same as clicking the send button

mailItem.GetInspector.Activate();
System.Windows.Forms.SendKeys.SendWait("%S");
0
votes

I dont think you can do this. The only way I know of to force a spell check other than tap into sending the item via an event is to fire execute on the spellcheck button on the tool bar.

Marcus