PC Review


Reply
Thread Tools Rate Thread

Capturing Outlook Forms Events

 
 
Duke2
Guest
Posts: n/a
 
      28th Aug 2009
Hi,

I'm new to Outlook forms programing, so this quesiotn may sound silly to you
guys. Please bear with me, if so.

I'm trying to retrieve the message ID when a user clicks on a message on
Outlook 2007 and run a script (a macro?) and thereby do some checks and if
the check qualifies the message for a certain condition replace the mesage
with a standard message that's stored locally as an .msg file.

I know how to call a macro but don't know how to link a macro to an event.
Also I don't know how to parse an msg file into IPM.Note form.

Could you help me by giving me some tips, pointing to some reference
matirals online and/or offline (books). I know these are very basic
operations in Outlook programming, but I'm clueless.

Thanks
--
Duke
 
Reply With Quote
 
 
 
 
Sue Mosher [MVP]
Guest
Posts: n/a
 
      28th Aug 2009
Are you asking what event fires when the user clicks on an item in a folder
window? That has nothing to do with Outlook custom forms. The relevant event
is Explorer.SelectionChange event.

What do you mean by "message ID"? By "replace the message," do you mean
replace the entire Outlook message item? Or replace the message body?

To bring an .msg file into Outlook, use the Namespace.OpenSharedItem method.

The book and web site mentioned in my signature supplement the basic
information available in VBA Help.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Duke2" <(E-Mail Removed)> wrote in message
news:C0DDC369-A04A-4701-AE6A-(E-Mail Removed)...
> Hi,
>
> I'm new to Outlook forms programing, so this quesiotn may sound silly to
> you
> guys. Please bear with me, if so.
>
> I'm trying to retrieve the message ID when a user clicks on a message on
> Outlook 2007 and run a script (a macro?) and thereby do some checks and if
> the check qualifies the message for a certain condition replace the mesage
> with a standard message that's stored locally as an .msg file.
>
> I know how to call a macro but don't know how to link a macro to an event.
> Also I don't know how to parse an msg file into IPM.Note form.
>
> Could you help me by giving me some tips, pointing to some reference
> matirals online and/or offline (books). I know these are very basic
> operations in Outlook programming, but I'm clueless.
>
> Thanks
> --
> Duke



 
Reply With Quote
 
Duke2
Guest
Posts: n/a
 
      28th Aug 2009
Hi Sue,

Thanks for the quick response. I just bought your book "Outlook 2007
Programming" and just started learning Outlook programming.

I'm asking what event fires when the user clicks on an Outlook item, mainly
what events fire when user selects a message by clicking on an item on
Outlook main window. I didnt mean to say what events get fired on Windows
folder level.

I want to capture the unique ID of the message available in the header
called message_ID and then run a query against this message and see if it
qualifies for my special handling. If it does then I want to replace the
entire message with a stathc message that's stored locally in an msg file.

Thanks
--
Duke

 
Reply With Quote
 
Sue Mosher [MVP]
Guest
Posts: n/a
 
      28th Aug 2009
As I said, Explorer.SelectionChange is the event that fires when the user
clicks on an item in the main Outlook window.

To access the message header, you would use the PropertyAccessor object;
there's an example at
http://msdn.microsoft.com/en-us/libr...opertyaccessor.
It's VB.NET, but the basic approach would be similar in VBA, if that's what
you're writing code for.

What does "run a query against this message" mean in your scenario?
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Duke2" <(E-Mail Removed)> wrote in message
news:74EF8435-74FA-4596-A68A-(E-Mail Removed)...
> Hi Sue,
>
> Thanks for the quick response. I just bought your book "Outlook 2007
> Programming" and just started learning Outlook programming.
>
> I'm asking what event fires when the user clicks on an Outlook item,
> mainly
> what events fire when user selects a message by clicking on an item on
> Outlook main window. I didnt mean to say what events get fired on Windows
> folder level.
>
> I want to capture the unique ID of the message available in the header
> called message_ID and then run a query against this message and see if it
> qualifies for my special handling. If it does then I want to replace the
> entire message with a stathc message that's stored locally in an msg file.
>
> Thanks
> --
> Duke
>



 
Reply With Quote
 
Duke2
Guest
Posts: n/a
 
      28th Aug 2009
Hi Sue,

By runnig a query I meant, using the email's message ID, I'd run a DB query
against the database stored in the same network and then based on the
results, I'll decide to show the original contents or show a static message
from an msg file (stored locally). I have a back end process running (on
Exchange Server) that sniffs through all email contents and if any of them
have some keyowrds, I want them not be show to the user and instead show a
standard message.

Thank you for directing me to the VB.NET sample. I'll attempt to rewrite it
in VBA. However I have a question, if I want to do this in VB.NEt then I have
to develop an Outlook add-in using VSTO I assume. Please tell me if my
assumption is right. I prefer to write code in C# (or VB.NET) and VBA is my
second choice.

If I can access the message header through PropertyAccessor object, where
should I run the script to access it? This is the most confusing part to me.
As I said before I can write some macros, but don't know how to call them
and/or link them to events.

Thanks
Duke
 
Reply With Quote
 
Sue Mosher [MVP]
Guest
Posts: n/a
 
      28th Aug 2009
As I said in my earlier response, Explorer.SelectionChange is the event that
fits your scenario. Any good VSTO add-in sample for Outlook should show you
how to work with various event handlers in C#.

I'm not sure your complete scenario is workable, though, unless you plan to
completely replace the original message as it arrives. There's no separate
functionality for controlling what's displayed in the reading pane. Also,
users could turn on AutoPreview, which would show them some of the message
contents even before they click on a particular message. Since you already
have a server process running, maybe it should be doing the message
replacement operation.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Duke2" <(E-Mail Removed)> wrote in message
news:797FBA96-F112-4DC7-96CA-(E-Mail Removed)...
> Hi Sue,
>
> By runnig a query I meant, using the email's message ID, I'd run a DB
> query
> against the database stored in the same network and then based on the
> results, I'll decide to show the original contents or show a static
> message
> from an msg file (stored locally). I have a back end process running (on
> Exchange Server) that sniffs through all email contents and if any of them
> have some keyowrds, I want them not be show to the user and instead show a
> standard message.
>
> Thank you for directing me to the VB.NET sample. I'll attempt to rewrite
> it
> in VBA. However I have a question, if I want to do this in VB.NEt then I
> have
> to develop an Outlook add-in using VSTO I assume. Please tell me if my
> assumption is right. I prefer to write code in C# (or VB.NET) and VBA is
> my
> second choice.
>
> If I can access the message header through PropertyAccessor object, where
> should I run the script to access it? This is the most confusing part to
> me.
> As I said before I can write some macros, but don't know how to call them
> and/or link them to events.
>
> Thanks
> Duke



 
Reply With Quote
 
Duke2
Guest
Posts: n/a
 
      28th Aug 2009
Thank you for the reply. In my case though I can not use VSTO but should
stick to macros as I'm not allowed to install anything on client's machines.
I hope this is something that can be done in Outlook 2007.

Yes, my intention is to replace the whole message and not just few fields
like body, subject. However if I do this in the back-end, the replacement
will be permanent I assume. That's also something that's not allowed. I have
to preserve the original message and at the same time display a different
message to the user. If I can replace the complete message as it arrives, my
goal is achieved.
 
Reply With Quote
 
Sue Mosher [MVP]
Guest
Posts: n/a
 
      28th Aug 2009
Before you go down that road, you should be aware that there's no simple way
to distribute VBA code to other users; see
http://www.outlookcode.com/article.aspx?id=28 Also, users can delete VBA
code easily. How are you planning to avoid that?

> I have
> to preserve the original message and at the same time display a different
> message to the user. If I can replace the complete message as it arrives,
> my
> goal is achieved.


And do what with the original message? Also, if this is an Exchange
environment, wouldn't the user be able to see the full message with OWA?
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Duke2" <(E-Mail Removed)> wrote in message
news:5FCB489B-9A54-4A43-873A-(E-Mail Removed)...
> Thank you for the reply. In my case though I can not use VSTO but should
> stick to macros as I'm not allowed to install anything on client's
> machines.
> I hope this is something that can be done in Outlook 2007.
>
> Yes, my intention is to replace the whole message and not just few fields
> like body, subject. However if I do this in the back-end, the replacement
> will be permanent I assume. That's also something that's not allowed. I
> have
> to preserve the original message and at the same time display a different
> message to the user. If I can replace the complete message as it arrives,
> my
> goal is achieved.



 
Reply With Quote
 
Duke2
Guest
Posts: n/a
 
      28th Aug 2009
I thought by publishing into Organizational Forms Library, I can easily
distribute these macros to the users. But after looking at your post, I'm bit
worried.

my intention is not to show the message's original contents if it qualifies
my criteria (as I described before). I've also modified OWA premium pages to
do the same thing. OWA part is prety much complete, but it appears that
without installing anything on client's machine, I wont be able to do the
same thing with Outlook.

If we forget the distribution difficulty for a minute and think this only
needs to work on a single Outlook instance, how can I capture the events and
call a macro? Can you show me an example of this?

Thanks
Duke




 
Reply With Quote
 
Sue Mosher [MVP]
Guest
Posts: n/a
 
      28th Aug 2009
Forms published to the Organizational Forms library run VBScript code, not
VBA code, and would not provide a solution for your scenario.

These articles on Outlook events include VBA code samples and are also
available in VBA Help on your machine:

http://msdn.microsoft.com/en-us/library/bb147654.aspx -
Explorer.SelectionChange
http://msdn.microsoft.com/en-us/library/bb147644.aspx -
Inspectors.NewInspector

Still looking for an answer to my question about what you plan to do with
the original message's content if you replace all the fields with data from
some other source.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Duke2" <(E-Mail Removed)> wrote in message
news:526832FB-2545-42AD-A465-(E-Mail Removed)...
>I thought by publishing into Organizational Forms Library, I can easily
> distribute these macros to the users. But after looking at your post, I'm
> bit
> worried.
>
> my intention is not to show the message's original contents if it
> qualifies
> my criteria (as I described before). I've also modified OWA premium pages
> to
> do the same thing. OWA part is prety much complete, but it appears that
> without installing anything on client's machine, I wont be able to do the
> same thing with Outlook.
>
> If we forget the distribution difficulty for a minute and think this only
> needs to work on a single Outlook instance, how can I capture the events
> and
> call a macro? Can you show me an example of this?
>
> Thanks
> Duke
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Capturing Outlook Forms Events Sue Mosher [MVP] Microsoft Outlook Form Programming 1 28th Aug 2009 08:25 PM
Problems with capturing Custom Popup Menus Click Events for CommandbarButton in Forms shane Parkinson Microsoft Access Form Coding 0 11th Jul 2007 12:29 PM
Capturing Keypresses in an Outlook Forms Multiline Textbox Robert Brown Microsoft Outlook Form Programming 3 26th Oct 2004 12:39 PM
Capturing events not in windows forms =?Utf-8?B?QXBwaWFuIEJyZW5kYW4=?= Microsoft C# .NET 0 3rd Sep 2004 10:19 PM
Capturing events on newly added folders in an Outlook Addin Simon Bates Microsoft Outlook Program Addins 0 20th Aug 2003 11:38 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:09 PM.