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)

Andrew Lockwood October 26th 08 07:14 AM

Trapping RDO (Redemption) Events in Delphi
 
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 October 26th 08 08:16 PM

Trapping RDO (Redemption) Events in Delphi
 
What is the rest of your code? When and how do you initialize RDOMail?

--
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 October 27th 08 12:00 PM

Trapping RDO (Redemption) Events in Delphi
 
Dmitry

Thanks for your reply - I really appreciate all your help.

What I want to do is to link to an item when it is received or sent.

So, for example, in the OnItemSend procedure, I have

procedure TADTAddIn.OnItemSend(Sender: TOutlookApplication; const Item:
IDispatch; var Cancel: WordBool)
begin
try
try
FCurrentItem := TRDOMailItem.Create(Item); // FCurrentItem is a
private TRDOMailItem of TADTAddIn
......
except
//oops...
end;

finally
end;
end;


unit uRDOOutlookTypes;

interface

uses ActiveX, Classes, OleServer, Redemption_TLB;

type
TRDOMailItem = class(TOleServer)
private
FOnModified : TNotifyEvent;
FOnDeleted : TNotifyEvent;
FOnMoved : TNotifyEvent;
FOnClose : TNotifyEvent;
FIntf : IUnknown;
function GetConnected: boolean;
protected
procedure InitServerData; override;
procedure InvokeEvent(DispID: TDispID; var Params: TVariantArray);
override;
public
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;
constructor Create(svrIntf: IUnknown); reintroduce; virtual;
destructor Destroy; override;
procedure Connect; override;
procedure ConnectTo(svrIntf: IUnknown);
procedure Disconnect; override;
property Intf : IUnknown read FIntf;
property Connected : boolean read GetConnected;
end;

implementation

{ TRDOMailItem }

procedure TRDOMailItem.Connect;
var
punk: IUnknown;

begin
if FIntf = nil then
begin
punk := GetServer;
ConnectEvents(punk);
Fintf:= punk;
end;
end;


procedure TRDOMailItem.ConnectTo(svrIntf: IUnknown);
begin
Disconnect;
FIntf := svrIntf;
ConnectEvents(FIntf);
end;

constructor TRDOMailItem.Create(svrIntf: IUnknown);
begin
inherited Create(nil);
AutoConnect:=false;
ConnectKind:=ckAttachToInterface;
ConnectTo(svrIntf);
end;

destructor TRDOMailItem.Destroy;
begin
Disconnect;
inherited;
end;

procedure TRDOMailItem.Disconnect;
begin
if Fintf nil then
begin
DisconnectEvents(FIntf);
FIntf := nil;
end;
end;

function TRDOMailItem.GetConnected: boolean;
var CPC:IUnknown;
begin
Result:=(FIntf nil) and
Succeeded(FIntf.QueryInterface(IConnectionPointCon tainer, CPC))
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 TRDOMailItem.InvokeEvent(DispID: TDispID; var Params:
TVariantArray);
var
Cancel : WordBool;

begin
case DispID of
-1:
Exit; // DISPID_UNKNOWN

1:
begin
if Assigned(FOnModified) then
FOnModified(Self);
end;
end;
end;





"Dmitry Streblechenko" wrote in message
...
What is the rest of your code? When and how do you initialize RDOMail?

--
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 3rd 08 09:19 AM

Trapping RDO (Redemption) Events in Delphi
 
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 3rd 08 04:42 PM

Trapping RDO (Redemption) Events in Delphi
 
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 3rd 08 05:33 PM

Trapping RDO (Redemption) Events in Delphi
 
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 3rd 08 08:37 PM

Trapping RDO (Redemption) Events in Delphi
 
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 4th 08 08:01 AM

Trapping RDO (Redemption) Events in Delphi
 
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 4th 08 09:26 PM

Trapping RDO (Redemption) Events in Delphi
 
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 05:11 PM

Trapping RDO (Redemption) Events in Delphi
 
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 07:57 PM.

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