how to detect programmatically if some code is runing in wordmail

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi dear all,
I have some code running in a com add-in with a Word connector , and I would
like to know from this code if the word application instance running the dll
code is a standalone word application or a wordmail instance.

if it is a wordmail instance , I would like to be able from the routine to
send the mail from the current outlook inspector. How can I achieve this ?

Any sample code is much appreciated
Best regards
 
Window.EnvelopeVisible = True tells you that it's a WordMail item.

Offhand I don't know of a way to get from that Word window back to the
specific Outlook Inspector directly. You could iterate the
Outlook.Inspectors collection and look for the Caption of each Inspector
window and compare it to the caption of the Word window. That wouldn't work
however until the first Inspector.Activate event had fired already.

You could get the class name of the Word window from the Win32 API and then
look for all open classes in Windows to match the class id. You could look
for a class of "OpusApp".
 
First of all Thank you much for your kind answer Ken,
Thank you much for the first point according to window.envelopeVisible=true

The second point is still not clear to me , could you show me a little
snippet ?

thank you much ken
 
You could get the Word Window.Caption since you have your Word code. Then
you could get the Outlook Inspectors collection and iterate it. For each
Inspector check Inspector.Caption and see if they match. If so that most
likely is the WordMail window.

An alternative is to use FindWindow in the Win32 API to get the window with
that caption, then you can use GetClassName to verify that it's "OpusApp" to
make sure it's a WordMail window.
 
Thanks Ken,

From that when I get the right inspector item in outlook , what piece code
is needed to send the said email after checking that I ghave at least one
recipient filled ?
 
Item.Send. Use the Object Browser to check for all methods, events and
properties.

That would bring up the security prompts unless this is a trusted COM addin
however. Outlook 2003 will trust a correctly written COM addin (you derive
your Outlook application object from the Application object passed in
On_Connection and all Outlook objects from that Application object). Earlier
versions require use of the Exchange public folders security admin form to
be trusted. And .NET addins are never trusted.

I usually use Redemption (www.dimastr.com/redemption) to avoid all the
security problems and therefore I don't have to worry about Outlook version
and whether it trusts addins or if Exchange is being used.
 
Back
Top