Error message after call to Outlook

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

Error message after call to Outlook
"Incorrect function" 
Robin Anderson




Posts: 3
Joined: 2010-08-31
Hello.

I've installed the latest version of secman.dll and am using it in a Delphi 2007 application. All works as expected. However, the following message setup gives an error message indicting an "Incorrect function" if I use the oMessage.Display. No message appears if I just "send" the message. The email is properly sent in both scenarios (Office 2003 and 2007)... just that the dialog message is annoying. What have I messed up on?


oMessage := oOutlook.CreateItem( MAIL_ITEM );
oMessage.To := 'mail@mailsystem.com';
oMessage.Subject := 'Topic';

oMessage.Body := '';
oMessage.Attachments.Add( document );

if rbDisplay.Checked then
oMessage.Display
else
oMessage.Send;

Thanks for any hints and cheers,
R
Posted 31 Aug, 2010 15:47:29 Top
Alexander Solomenko




Posts: 140
Joined: 2009-02-27
Hi Robin,

It is normal,
Please see http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook._mailitem.display.aspx
The Display method is supported for explorer and inspector windows for the sake of backward compatibility. To activate an explorer or inspector window, use the Activate method.
Regards,
Aleksandr Solomenko
Posted 01 Sep, 2010 09:13:42 Top
Robin Anderson




Posts: 3
Joined: 2010-08-31
Thanks for the pointer Aleksandr.

I've tried what you suggested in the following formats:

[1] oMessage.Activate;
[2] oMessage.Activate( True );
[3] oOutlook.Activate; // Outlook application OLE object.

I get error message "Method Activate not supported by automation object". Can you give me a Delphi (or C++) code snippet demonstrating the use of the Activate method? There was no samples in the documentation links provide.

Cheers,
R
Posted 01 Sep, 2010 11:05:10 Top
Alexander Solomenko




Posts: 140
Joined: 2009-02-27
Hi Robin,

Sorry for incomplete information
The Active method must be called in the Inspector object.

Please to use the following code:
oMessage.GetInspector.Activate
Regards,
Aleksandr Solomenko
Posted 01 Sep, 2010 16:21:26 Top
Robin Anderson




Posts: 3
Joined: 2010-08-31
Thank's Aleksandr ... but I'm still gettting errors.

oMessage.GetInspector.Activate; - "Incorrect Function"
oMessage.GetInspector.Activate := True; - "Read Only"

Is there any documentation on the methods for the OLE object (oOutlook) and item (oMessage) in my snippet... whgich I cobbled together from samples in this forum?

I do appreciate the assistance. Other than this niggling error, the connection from my application to Outlook is brilliant. Well done!

Cheers,
R
Posted 02 Sep, 2010 09:22:23 Top
Alexander Solomenko




Posts: 140
Joined: 2009-02-27
Hi Robin,

I created a test project in which two ways to open the inspector are used.
When using the "Display" function the "Incorrect function" error occurs, while using the "Activate" function works fine.
I sent it to your email address. Please check it out and let me now about the result.
Regards,
Aleksandr Solomenko
Posted 02 Sep, 2010 09:47:22 Top