No announcement yet.

Outlook 2003 Add-in - Getting Process ID of Winword when used by Outlook.

  • Filter
  • Time
  • Show
Clear All
new posts

  • Outlook 2003 Add-in - Getting Process ID of Winword when used by Outlook.


    I am after some help please. I am in the process of writing an add-in for Outlook 2003 using VB2005 and VSTO. The add-in, links to a database that contains different lists of members for which emails/newsletters can be sent to. Within the add-in the user has the option to draft one email and send it to each member in the selected list as an individual email with a personalised greeting.

    To get the emails to send individually, I intercept and cancel the send event. Once cancelled, I create a copy of the drafted email for each recipient, and send the copied email. When each recipient has been sent an email, I close the drafted email using the following code;

    If msg.Application.ActiveInspector.IsWordMail Then
    'The email message has been drafted within Outlook using word. Close the email using the commandbars.execute method

    'The email is drafted by Outlook, to close use...
    msg.Application.ActiveInspector.Close(Outlook.OlIn spectorClose.olDiscard)


    Everything seems to work as I expect, however, if the email is sent using MS Word to draft the email, MS Word is left open and as the topmost window.

    Is there a way to close the MS Word application that was opened to draft the email?

    I am thinking that if I could identify the Process ID of MS Word that was opened to draft the email, I could stop the process. How would I do this?

    I would greatly appreciate any help that could be offered.