Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Trapping RDO (Redemption) Events in Delphi (http://www.outlookbanter.com/outlook-vba/80795-trapping-rdo-redemption-events-delphi.html)

Dmitry Streblechenko November 5th 08 06:17 PM

Trapping RDO (Redemption) Events in Delphi
 
Either that or Items.ItemAdd event on the Deleted Item folder.
*If* the message gets moved to the Deleted Items folder - I always use
Shift-Delete.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Andrew Lockwood" wrote in message
...
Does that mean that the OnMoved event would fire when the item is moved to
the Deleted Items folder? If so, presumably I could achieve what I want
by trapping this event instead?


Andrew

"Dmitry Streblechenko" wrote in message
...
OnDeleted event will fire only *after* the message is deleted, so it will
not help you at all.
All MAPI events are asynchronous and fire only after the action has
already been completed.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Andrew Lockwood" wrote in message
...
What I am ultimately trying to do is to ensure that a user adds a
project number to all incoming and outgoing emails, and to prevent the
user deleting any emails that have a project number tag.

So I thought that I could prompt the user for the project number tag
when they send (OnItemSend) and when they read it (OnSelectionChange),
and then check that the tag is correctly set before they delete it (and
prevent them deleting it if it has a project number tag). So I was
hoping that I could use the OnDeleted event of RDOMail to achieve this.

I have just tried

procedure TADTAddIn.OnSelectionChange(Sender: TObject);
var
ItemSelected, SelectedItemChanged : boolean;
CurrentItem : OleVariant;

begin
CurrentItem := GetSelectedItem(GApplication);
FCurrentItem := TRDOMailItem.Create(CurrentItem); // FCurrentItem is
a private property of my AddIn
...
...
end;

in conjuction with my other code previously posted, but still nothing is
happening - the InvokeEvent
procedure is never executed.


Andrew

"Dmitry Streblechenko" wrote in message
...
Why do you need an event for that?
Why not simply add the property in the ItemSend event handler?
You should be able to set up an event sink on an RDOMail object in the
OnSelectionChange event handler. Again, how do you do that and why?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Andrew Lockwood" wrote in message
...
Basically, I want to add a user property to the item denoting a
category for the email - normally a project number. I realise that I
could do this by creating a custom form and adding a drop down box or
whatever to set the category before clicking the send button.

But even if that is the better way to treat outgoing emails, I would
still like to understand how to use the RDOMail item object and to
trap its events - presumably I should be able to create an instance of
an RDOMail item in the OnSelectionChange procedure.


Andrew


"Dmitry Streblechenko" wrote in message
...
When a message is being sent, you should release all the references
to it; it now belongs to the spooler.
The message will be moved to the Outbox and, after it is successfully
sent, to the Sent Items folder.In bot hcases it will be a different
message, nit the one you had in the ItemSend event handler.
What exactly and why are you trying to do?


--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Andrew Lockwood" wrote in message
...
Dmitry

What is the rest of your code? When and how do you initialize
RDOMail?

I posted answers to these questions on 27th October. If you could
throw some light on what I am doing wrong, I would be really
grateful.


Andrew Lockwood


--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Andrew Lockwood" wrote in message
...
Apologies for posting a question about Delphi, but I cannot find
an active Delphi forum for this type of issue.

Can anyone explain to me / show me some sample code for trapping
the events of an RDOMail item, for example. I have tried creating
a wrapper as follows


TRDOMailItem = class(TOleServer)
private
FIntf : IRDOMail;
FOnModified : TNotifyEvent;
FOnDeleted : TNotifyEvent;
FOnMoved : TNotifyEvent;
FOnClose : TNotifyEvent;
function GetDefaultInterface: IRDOMail;
//FOnMovedEx : (const OldParentEntryId: WideString; const
NewParentEntryID: WideString); dispid 5;
protected
procedure Connect;
procedure ConnectTo(svrIntf : IRDOMail);
procedure Disconnect; override;
procedure InitServerData; override;
procedure InvokeEvent(DispID: TDispID; var Params:
TVariantArray); override;
public
//need to add more events
property OnModified : TNotifyEvent read FOnModified write
FOnModified;
property OnDeleted : TNotifyEvent read FOnDeleted write
FOnDeleted;
property OnMoved : TNotifyEvent read FOnMoved write FOnMoved;
property OnClose : TNotifyEvent read FOnClose write FOnClose;
end;

procedure TRDOMailItem.InitServerData;
const
CServerData: TServerData = (
ClassID: '{02ABB20A-FB8A-4433-8D66-135C6CCD0F32}';
//Class_xxx
IntfIID: '{D85047E0-7767-4D48-86B6-28BDB5728ABB}'; //IID_xxx
EventIID: '{0D00E38E-315D-49D5-9331-80BC1559C0E7}'; //DIID_xxx
LicenseKey: nil;
Version: 500);

begin
ServerData := @CServerData;
end;

procedure TRDOOutlookServer.Connect;
var punk: IUnknown;
begin
if FIntf = nil then
begin
punk := GetServer;
ConnectEvents(punk);
Fintf:= punk;
end;
end;


but it doesn't work - it complies and runs OK, but the InvokeEvent
procedure is never executed, so I cannot capture the events.




















Andrew Lockwood November 5th 08 10:02 PM

Trapping RDO (Redemption) Events in Delphi
 
Thanks - sorry to be a bore, but does that not bring me back to my original
question - how do I trap the RDOMail events? I would have expected the code
I have already posted to work, but it doesn't.


Andrew

"Dmitry Streblechenko" wrote in message
...
Either that or Items.ItemAdd event on the Deleted Item folder.
*If* the message gets moved to the Deleted Items folder - I always use
Shift-Delete.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Andrew Lockwood" wrote in message
...
Does that mean that the OnMoved event would fire when the item is moved
to the Deleted Items folder? If so, presumably I could achieve what I
want by trapping this event instead?


Andrew

"Dmitry Streblechenko" wrote in message
...
OnDeleted event will fire only *after* the message is deleted, so it
will not help you at all.
All MAPI events are asynchronous and fire only after the action has
already been completed.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Andrew Lockwood" wrote in message
...
What I am ultimately trying to do is to ensure that a user adds a
project number to all incoming and outgoing emails, and to prevent the
user deleting any emails that have a project number tag.

So I thought that I could prompt the user for the project number tag
when they send (OnItemSend) and when they read it (OnSelectionChange),
and then check that the tag is correctly set before they delete it (and
prevent them deleting it if it has a project number tag). So I was
hoping that I could use the OnDeleted event of RDOMail to achieve this.

I have just tried

procedure TADTAddIn.OnSelectionChange(Sender: TObject);
var
ItemSelected, SelectedItemChanged : boolean;
CurrentItem : OleVariant;

begin
CurrentItem := GetSelectedItem(GApplication);
FCurrentItem := TRDOMailItem.Create(CurrentItem); // FCurrentItem is
a private property of my AddIn
...
...
end;

in conjuction with my other code previously posted, but still nothing
is happening - the InvokeEvent
procedure is never executed.


Andrew

"Dmitry Streblechenko" wrote in message
...
Why do you need an event for that?
Why not simply add the property in the ItemSend event handler?
You should be able to set up an event sink on an RDOMail object in the
OnSelectionChange event handler. Again, how do you do that and why?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Andrew Lockwood" wrote in message
...
Basically, I want to add a user property to the item denoting a
category for the email - normally a project number. I realise that I
could do this by creating a custom form and adding a drop down box or
whatever to set the category before clicking the send button.

But even if that is the better way to treat outgoing emails, I would
still like to understand how to use the RDOMail item object and to
trap its events - presumably I should be able to create an instance
of an RDOMail item in the OnSelectionChange procedure.


Andrew


"Dmitry Streblechenko" wrote in message
...
When a message is being sent, you should release all the references
to it; it now belongs to the spooler.
The message will be moved to the Outbox and, after it is
successfully sent, to the Sent Items folder.In bot hcases it will be
a different message, nit the one you had in the ItemSend event
handler.
What exactly and why are you trying to do?


--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Andrew Lockwood" wrote in message
...
Dmitry

What is the rest of your code? When and how do you initialize
RDOMail?

I posted answers to these questions on 27th October. If you could
throw some light on what I am doing wrong, I would be really
grateful.


Andrew Lockwood


--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Andrew Lockwood" wrote in message
...
Apologies for posting a question about Delphi, but I cannot find
an active Delphi forum for this type of issue.

Can anyone explain to me / show me some sample code for trapping
the events of an RDOMail item, for example. I have tried
creating a wrapper as follows


TRDOMailItem = class(TOleServer)
private
FIntf : IRDOMail;
FOnModified : TNotifyEvent;
FOnDeleted : TNotifyEvent;
FOnMoved : TNotifyEvent;
FOnClose : TNotifyEvent;
function GetDefaultInterface: IRDOMail;
//FOnMovedEx : (const OldParentEntryId: WideString; const
NewParentEntryID: WideString); dispid 5;
protected
procedure Connect;
procedure ConnectTo(svrIntf : IRDOMail);
procedure Disconnect; override;
procedure InitServerData; override;
procedure InvokeEvent(DispID: TDispID; var Params:
TVariantArray); override;
public
//need to add more events
property OnModified : TNotifyEvent read FOnModified write
FOnModified;
property OnDeleted : TNotifyEvent read FOnDeleted write
FOnDeleted;
property OnMoved : TNotifyEvent read FOnMoved write FOnMoved;
property OnClose : TNotifyEvent read FOnClose write FOnClose;
end;

procedure TRDOMailItem.InitServerData;
const
CServerData: TServerData = (
ClassID: '{02ABB20A-FB8A-4433-8D66-135C6CCD0F32}';
//Class_xxx
IntfIID: '{D85047E0-7767-4D48-86B6-28BDB5728ABB}'; //IID_xxx
EventIID: '{0D00E38E-315D-49D5-9331-80BC1559C0E7}';
//DIID_xxx
LicenseKey: nil;
Version: 500);

begin
ServerData := @CServerData;
end;

procedure TRDOOutlookServer.Connect;
var punk: IUnknown;
begin
if FIntf = nil then
begin
punk := GetServer;
ConnectEvents(punk);
Fintf:= punk;
end;
end;


but it doesn't work - it complies and runs OK, but the
InvokeEvent procedure is never executed, so I cannot capture the
events.






















Dmitry Streblechenko November 6th 08 12:17 AM

Trapping RDO (Redemption) Events in Delphi
 
You would need the RDOItems.ItemAdd event, where RDOItems is retreived from
RDOFolder.Items collection, where RDOFolder points to the Deleted Items
folder.
This is the same as in the Outlook Obejc tModel.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Andrew Lockwood" wrote in message
...
Thanks - sorry to be a bore, but does that not bring me back to my
original question - how do I trap the RDOMail events? I would have
expected the code I have already posted to work, but it doesn't.


Andrew

"Dmitry Streblechenko" wrote in message
...
Either that or Items.ItemAdd event on the Deleted Item folder.
*If* the message gets moved to the Deleted Items folder - I always use
Shift-Delete.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Andrew Lockwood" wrote in message
...
Does that mean that the OnMoved event would fire when the item is moved
to the Deleted Items folder? If so, presumably I could achieve what I
want by trapping this event instead?


Andrew

"Dmitry Streblechenko" wrote in message
...
OnDeleted event will fire only *after* the message is deleted, so it
will not help you at all.
All MAPI events are asynchronous and fire only after the action has
already been completed.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Andrew Lockwood" wrote in message
...
What I am ultimately trying to do is to ensure that a user adds a
project number to all incoming and outgoing emails, and to prevent the
user deleting any emails that have a project number tag.

So I thought that I could prompt the user for the project number tag
when they send (OnItemSend) and when they read it (OnSelectionChange),
and then check that the tag is correctly set before they delete it
(and prevent them deleting it if it has a project number tag). So I
was hoping that I could use the OnDeleted event of RDOMail to achieve
this.

I have just tried

procedure TADTAddIn.OnSelectionChange(Sender: TObject);
var
ItemSelected, SelectedItemChanged : boolean;
CurrentItem : OleVariant;

begin
CurrentItem := GetSelectedItem(GApplication);
FCurrentItem := TRDOMailItem.Create(CurrentItem); // FCurrentItem
is a private property of my AddIn
...
...
end;

in conjuction with my other code previously posted, but still nothing
is happening - the InvokeEvent
procedure is never executed.


Andrew

"Dmitry Streblechenko" wrote in message
...
Why do you need an event for that?
Why not simply add the property in the ItemSend event handler?
You should be able to set up an event sink on an RDOMail object in
the OnSelectionChange event handler. Again, how do you do that and
why?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Andrew Lockwood" wrote in message
...
Basically, I want to add a user property to the item denoting a
category for the email - normally a project number. I realise that
I could do this by creating a custom form and adding a drop down box
or whatever to set the category before clicking the send button.

But even if that is the better way to treat outgoing emails, I would
still like to understand how to use the RDOMail item object and to
trap its events - presumably I should be able to create an instance
of an RDOMail item in the OnSelectionChange procedure.


Andrew


"Dmitry Streblechenko" wrote in message
...
When a message is being sent, you should release all the references
to it; it now belongs to the spooler.
The message will be moved to the Outbox and, after it is
successfully sent, to the Sent Items folder.In bot hcases it will
be a different message, nit the one you had in the ItemSend event
handler.
What exactly and why are you trying to do?


--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Andrew Lockwood" wrote in message
...
Dmitry

What is the rest of your code? When and how do you initialize
RDOMail?

I posted answers to these questions on 27th October. If you could
throw some light on what I am doing wrong, I would be really
grateful.


Andrew Lockwood


--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Andrew Lockwood" wrote in message
...
Apologies for posting a question about Delphi, but I cannot find
an active Delphi forum for this type of issue.

Can anyone explain to me / show me some sample code for trapping
the events of an RDOMail item, for example. I have tried
creating a wrapper as follows


TRDOMailItem = class(TOleServer)
private
FIntf : IRDOMail;
FOnModified : TNotifyEvent;
FOnDeleted : TNotifyEvent;
FOnMoved : TNotifyEvent;
FOnClose : TNotifyEvent;
function GetDefaultInterface: IRDOMail;
//FOnMovedEx : (const OldParentEntryId: WideString; const
NewParentEntryID: WideString); dispid 5;
protected
procedure Connect;
procedure ConnectTo(svrIntf : IRDOMail);
procedure Disconnect; override;
procedure InitServerData; override;
procedure InvokeEvent(DispID: TDispID; var Params:
TVariantArray); override;
public
//need to add more events
property OnModified : TNotifyEvent read FOnModified write
FOnModified;
property OnDeleted : TNotifyEvent read FOnDeleted write
FOnDeleted;
property OnMoved : TNotifyEvent read FOnMoved write FOnMoved;
property OnClose : TNotifyEvent read FOnClose write FOnClose;
end;

procedure TRDOMailItem.InitServerData;
const
CServerData: TServerData = (
ClassID: '{02ABB20A-FB8A-4433-8D66-135C6CCD0F32}';
//Class_xxx
IntfIID: '{D85047E0-7767-4D48-86B6-28BDB5728ABB}';
//IID_xxx
EventIID: '{0D00E38E-315D-49D5-9331-80BC1559C0E7}';
//DIID_xxx
LicenseKey: nil;
Version: 500);

begin
ServerData := @CServerData;
end;

procedure TRDOOutlookServer.Connect;
var punk: IUnknown;
begin
if FIntf = nil then
begin
punk := GetServer;
ConnectEvents(punk);
Fintf:= punk;
end;
end;


but it doesn't work - it complies and runs OK, but the
InvokeEvent procedure is never executed, so I cannot capture the
events.

























All times are GMT +1. The time now is 06:43 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com