Triggering Spell Check on Send

Add-in Express™ Support Service
That's what is more important than anything else

Triggering Spell Check on Send
 
Donald Jugan




Posts: 8
Joined: 2006-10-24
I have code in an Outlook Plugin that calls the MailItem.Send method. The message is sent, but the message is not spell checked before it is sent, even if the user's "Always Spell Check Before Sending" option is set in Outlook.

Is there any way to make sure that the spell check is performed before a message is sent via the MailItem.Send Method?

Alternatively, how can I programatically determin the value of the "Always Spell Check Before Sending" option and manually trigger the spell check before I call the MailItem.Send method?
Posted 24 Oct, 2006 11:08:22 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Donald.

Do you create a new email manually in the add-in code?
Posted 24 Oct, 2006 12:35:23 Top
Donald Jugan




Posts: 8
Joined: 2006-10-24
No, I get it from the current inspector.

Here's a snippet of from the code that handles the click event of my inspector toolbar button:


Private Sub ibtnSendAndFile_Click(ByVal sender As Object) Handles ibtnSendAndFile.Click
  Dim mi As Outlook.MailItem = OutlookApp.ActiveInspector.CurrentItem()
  ..
  (code to retrieve SourceType,SourceNumber, and Executive Interest)
  ..
  FileMessage(r.SourceType, r.SourceNumber, r.ExecutiveInterest, mi)
  mi.Send()
End Sub
Posted 24 Oct, 2006 12:50:44 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Donald.

In this case you can use the ADXBuiltInControl component to connect to the Spelling button in the inspector. Then you need to call the Execute method of the Office button before you send the email.
E.g.

Private Sub ibtnSendAndFile_Click(ByVal sender As Object) Handles ibtnSendAndFile.Click
Dim mi As Outlook.MailItem = OutlookApp.ActiveInspector.CurrentItem()
..
(code to retrieve SourceType,SourceNumber, and Executive Interest)
..
FileMessage(r.SourceType, r.SourceNumber, r.ExecutiveInterest, mi)

adxBuiltInControl1.ControlObj.Execute()

mi.Send()
End Sub
Posted 25 Oct, 2006 07:55:21 Top
Donald Jugan




Posts: 8
Joined: 2006-10-24
The BuiltInControlsScanner reports that the ID of the Spellcheck menu item in the inspector is 2. When I set up an adxBuiltInControl with and ID of 2, and check the IsConnected property at runtime, it always returns false.

So I tried another tatic. Since clicking the "Send" button on the inspector triggers a spell check if the user's "Spell Check before Sending" option is set, I hooked up the adxBuiltInControl to ID 2617. But when I call the ConrolObj.Execute method, I get the following error:

Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

Posted 25 Oct, 2006 10:56:24 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Donald.

In this case you can add the 'Send' built-in button on your command bar to run your code before the email is sent.
Please download an example:
http://www.add-in-express.com/projects/olbuilincontrols.zip
Posted 26 Oct, 2006 06:59:54 Top
Donald Jugan




Posts: 8
Joined: 2006-10-24
Sergey,

I have added a button labled "Send and File" to my inspector commandbar with an ID of 2617. Clicking this button does what I expect it to. It runs the code in the Click Handler sub and then sends the message.

At this point, I thought the problem was solved, and I deployed my plugin at my company. However, on some coputers, the "Send and File" button Replaces the standard "Send" button. On other computers, both the "Send" and "Send and File" buttons are visible, as I intended. I have witnessed both behaviors on Outlook 2002 and Outlook 2003.

Do you have any idea what might be causing this?
Posted 27 Oct, 2006 13:50:13 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Donald.

I tested the code on a PC with Outlook XP installed. It worked properly.
Are you sure that e-mail accounts have been added on the problematic PC in Outlook XP ? If there are no accounts, the Send button is not visible.
Posted 28 Oct, 2006 10:55:47 Top
Donald Jugan




Posts: 8
Joined: 2006-10-24
I found the cause. I have code that sets the visible property of my command bar button to true or false, depending on whether or not the SenderName property of the current item in the inspector is an empty string or not. Apparantly, when I set the visible property to false of the adxCommandbarbutton that has an ID of 2617, the built-in send button is also hidden. However, setting visible=true does not make the built-in button visible.
Posted 01 Nov, 2006 11:09:45 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Donald.

Try to find the built-in control in the Standard command bar using the FindControlObj method of the addinmodule and then set the visible=true individually.
Posted 02 Nov, 2006 04:55:04 Top