Capturing Outlook Forms Events

Status
Not open for further replies.
D

Duke2

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
 
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

"Duke2" <Duke2> wrote in message

news:C0DDC369-A04A-4701-AE6A-2E73C50AD85B@microsoft.com...
> 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
 
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
 
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/lib...2007whatsnewdeveloperspart2__propertyaccessor.

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

"Duke2" <Duke2> wrote in message

news:74EF8435-74FA-4596-A68A-34BB48B5C386@microsoft.com...
> 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
>
 
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
 
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

"Duke2" <Duke2> wrote in message

news:797FBA96-F112-4DC7-96CA-FC6519468A5D@microsoft.com...
> 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
 
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.
 
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

"Duke2" <Duke2> wrote in message

news:5FCB489B-9A54-4A43-873A-33B9D3456063@microsoft.com...
> 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.
 
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
 
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

"Duke2" <Duke2> wrote in message

news:526832FB-2545-42AD-A465-9362D948A631@microsoft.com...
> 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

>
 
I'm sorry for not being clear on what am I going to do to the original

message. I'm simply not going to show it the recipient, but then forward a

copy (through a back end process run on Exchagne Server) to an auditor and

preserve it as evidence. In case the auditor gives the approval I'll remove

the blocked status on the message and afterwards user will be able to see the

original contents.

Thanks for the links, I'll check them out now.

Duke

BTW: Pete McClean told me to say hi to you.
 
This sounds like a scenario that should be implemented totally at the server

level, with no client-side functionality involved, much as some spam filters

operate.

Sue Mosher

"Duke2" <Duke2> wrote in message

news:4A677945-AF79-4A96-BD69-83C92CABD86C@microsoft.com...
> I'm sorry for not being clear on what am I going to do to the original
> message. I'm simply not going to show it the recipient, but then forward a
> copy (through a back end process run on Exchagne Server) to an auditor
> and
> preserve it as evidence. In case the auditor gives the approval I'll
> remove
> the blocked status on the message and afterwards user will be able to see
> the
> original contents.

> Thanks for the links, I'll check them out now.
> Duke

> BTW: Pete McClean told me to say hi to you.
 
Hi Sue,

Thank you very much for the advise. I'm now convinced that doing this

operation at client side is not possible.

However to do this at server side, I need to capture message selection event

and then run my check on the server. Do you think Exchange will allow me to

capture message selection events? I know this is something that's not

possible with EWS as it's essentially a request-based set of operations.
 
Message selection, being a client function, doesn't fire an event on the

server. But if you modify the contents of the all the messages as they

arrive it, you don't need selection.

Sue Mosher

"Duke2" <Duke2> wrote in message

news:3C709176-5371-42A8-B647-F39B37EE0FBB@microsoft.com...
> Hi Sue,

> Thank you very much for the advise. I'm now convinced that doing this
> operation at client side is not possible.

> However to do this at server side, I need to capture message selection
> event
> and then run my check on the server. Do you think Exchange will allow me
> to
> capture message selection events? I know this is something that's not
> possible with EWS as it's essentially a request-based set of operations.
 
Hi Sue,

I'm sorry for making things confusing. Let me explain my requirement in a

differnet (hopefully) simpler way.

When a I select a message by clicking on it on Outlook, I want to capture

that event and inside that event I want to retrieve its message ID, and

instead of retrieving the message X (which it should retrieve), I want to

retrieve message Y from the same mailbox. Is this something possible to do in

Outlook forms?

Thanks

Duke
 
You mean "display," not "retrieve" for the messages, right? And you also

have the requirement, I presume, to prevent the user from seeing the

original item's content. If so, the only way to accomplish those goals is

for the original content to have been replaced *before* the user can do

anything with the item, and that's not something that can be done with an

Outlook form alone.

Sue Mosher

"Duke2" <Duke2> wrote in message

news:16759675-411D-40A3-ACA6-5126BEA89C6B@microsoft.com...
> Hi Sue,

> I'm sorry for making things confusing. Let me explain my requirement in a
> differnet (hopefully) simpler way.

> When a I select a message by clicking on it on Outlook, I want to capture
> that event and inside that event I want to retrieve its message ID, and
> instead of retrieving the message X (which it should retrieve), I want to
> retrieve message Y from the same mailbox. Is this something possible to do
> in
> Outlook forms?

> Thanks
> Duke
 
Hi Sue,

No I mean "retrieve" not just "display". Can I change Outlook to retrieve a

different message instead of the message it's supposed to retrieve from

server?

Thanks

Duke
 
In a programming context, "retrieve" generally means to return values from

some source. You can return whatever values you want from whatever source

you want, but if you want to block the message -- as your previous posts

indicated -- then I can only assume that you're talking about what is

displayed in the UI. So, that's "display," not "retrieve."

Or do you have some other scenario in mind?

Sue Mosher

"Duke2" <Duke2> wrote in message

news:144FAE33-14A8-405B-A5CC-317341AF26BA@microsoft.com...
> Hi Sue,

> No I mean "retrieve" not just "display". Can I change Outlook to retrieve
> a
> different message instead of the message it's supposed to retrieve from
> server?

> Thanks
> Duke

>
 
Yes in that context it's "display". I only want to display a different

message without replacing the original message in the server. So later on

when I want to, I can display the original message.

In perview however, I dont mind showing the original message.

Thanks

Duke
 
Well, I can't say that makes any sense to me. I mean, what's the point of

showing the user one thing in the reading pane and another thing in the

Inspector window. That sounds like a recipe for confusion. It's certainly

not a scenario that would fit any definition of blocking that I've ever

encountered.

But if you want to do it, just use a custom form for those items that runs

whatever code you want in the Item_Open event handler. Or, even simpler,

design the custom form so that the only visible page has a text box on it

with whatever it is you want the user to see, rather than the message body.

All subject, of course, to the warning I gave earlier about potential

problems with attachments if any of these items are forwarded.

Sue Mosher

"Duke2" <Duke2> wrote in message

news:3052217B-0B0B-41CA-8972-F9C16ED2E5A7@microsoft.com...
> Yes in that context it's "display". I only want to display a different
> message without replacing the original message in the server. So later on
> when I want to, I can display the original message.

> In perview however, I dont mind showing the original message.

> Thanks
> Duke

>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
S Re: Capturing Outlook Forms Events Outlook VBA and Custom Forms 1
A Capturing Send Variables without using Application_ItemSend in ThisOutlookSession Outlook VBA and Custom Forms 8
J Capturing forward event when multiple items are selected Using Outlook 0
D Capturing Data from a form into excel Outlook VBA and Custom Forms 1
B Capturing form data Outlook VBA and Custom Forms 1
A Outlook can't remember outlook.com, Exchange password. Using Outlook 0
S Related messages show in main Outlook window vice new Advanced Find windows Using Outlook 1
H Force Outlook 2019 with GMail 2-Step to Require Login? Using Outlook 0
G Retaining Tabs in outlook body Using Outlook 2
V Setting up Outlook 2021 on new computer Using Outlook 2
G Add Map It button to Custom Contacts Form in Outlook Outlook VBA and Custom Forms 1
X Custom icon (not from Office 365) for a macro in Outlook Outlook VBA and Custom Forms 1
Victor_50 Problem - Google Workspace will stop "unsafe" access to Outlook end 2024 Using Outlook 3
C New pc, new outlook, is it possible to import auto-complete emailaddress Using Outlook 4
T Outlook 365 won't take new working password Using Outlook 0
S Create Outlook Task from Template and append Body with Email Body Outlook VBA and Custom Forms 4
P Can't add custom field to custom Outlook form, it always adds to the Folder instead Outlook VBA and Custom Forms 2
B Sync Outlook Public Folders to Contacts Using Outlook 2
D Delete Outlook emails from MS server Using Outlook 12
B Outlook tasks and PDF Using Outlook 4
D Outlook 2019 is no longer asking for password ... Using Outlook 5
Kika Melo How to mark as Junk any message not from Contacts (in Outlook.com) Using Outlook 3
L Outlook attachments from OneDrive as links Using Outlook 0
G Outlook 365 My iCloud Outlook doesn’t work after reinstalling Microsoft365 on Windows 10 PC – now I get error message on contacts and calendar Using Outlook 1
T How to Export & Import GMAIL Contacts into Outlook 2021 ? Using Outlook 4
M Synchronization and backup of Outlook from local to server. Using Outlook 8
T How to get an EVENT COLOR option in Outlook 2021 ? Using Outlook 0
K How can I delete an e-mail from Outlook Using Outlook 1
V Outlook Error The Attempted operation Failed. An Object Could Not be found Outlook VBA and Custom Forms 0
P Yahoo/IMAP folder rename by Outlook desktop 365 Using Outlook 0
A Outlook 2019 folder counter Using Outlook 0
A Relocate Search Bar in Outlook Using Outlook 2
e_a_g_l_e_p_i Need clarification on 2-Step Verification for Gmail using Outlook 2021 Using Outlook 10
L Opening People Outlook 2021 Using Outlook 2
e_a_g_l_e_p_i Outlook 2021 not letting me setup my Gmail using pop Using Outlook 1
Geldner Problem submitting SPAM using Outlook VBA Form Outlook VBA and Custom Forms 2
P VBA to add email address to Outlook 365 rule Outlook VBA and Custom Forms 0
M Outlook 2016 outlook vba to look into shared mailbox Outlook VBA and Custom Forms 0
P Can no longer sync Outlook with iPhone calendar after iPhone update to 17.1.1 Using Outlook 7
O Outlook - Switch from Exchange to IMAP Using Outlook 2
e_a_g_l_e_p_i Is it possible to have a reminder in Outlook 2021 for every 90 days Using Outlook 3
farrissf Outlook 2016 Optimizing Email Searches in Outlook 2016: Seeking Insights on Quick Search vs Advanced Search Features Using Outlook 0
C Advanced search terms for "Outlook Data File" Using Outlook 1
N Reply to Outlook messages by moving messages to a specific Outlook folder Outlook VBA and Custom Forms 1
O How to find out the domain and server settings that my Outlook is using? Using Outlook 2
A Outlook 365 (OutLook For Mac)Move "On My Computer" Folder Items From Old To New Mac Computer Using Outlook 3
H Integrating Alexa & Outlook Pro 2021 Using Outlook 2
Z Automatically adjust Outlook Reading Pane from bottom to right depending on portrait or landscape window Using Outlook 1
Rupert Dragwater Background colors not saving in Outlook 365 Using Outlook 15
petunia Outlook tasks module sunsetting? Exchange Server Administration 3

Similar threads

Back
Top