A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Trapping RDO (Redemption) Events in Delphi



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 26th 08, 07:14 AM posted to microsoft.public.outlook.program_vba
Andrew Lockwood
external usenet poster
 
Posts: 10
Default 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.


Ads
  #2  
Old October 26th 08, 08:16 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default 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.



  #3  
Old October 27th 08, 12:00 PM posted to microsoft.public.outlook.program_vba
Andrew Lockwood
external usenet poster
 
Posts: 10
Default 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.





  #4  
Old November 3rd 08, 09:19 AM posted to microsoft.public.outlook.program_vba
Andrew Lockwood
external usenet poster
 
Posts: 10
Default 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.





  #5  
Old November 3rd 08, 04:42 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default 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.







  #6  
Old November 3rd 08, 05:33 PM posted to microsoft.public.outlook.program_vba
Andrew Lockwood
external usenet poster
 
Posts: 10
Default 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.









  #7  
Old November 3rd 08, 08:37 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default 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.











  #8  
Old November 4th 08, 08:01 AM posted to microsoft.public.outlook.program_vba
Andrew Lockwood
external usenet poster
 
Posts: 10
Default 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.













  #9  
Old November 4th 08, 09:26 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default 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.















  #10  
Old November 5th 08, 05:11 PM posted to microsoft.public.outlook.program_vba
Andrew Lockwood
external usenet poster
 
Posts: 10
Default 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.

















 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Missing Redemption Events DG Outlook and VBA 1 November 28th 07 01:50 PM
Inspector and trapping of shortcuts Petr Nehez Add-ins for Outlook 0 December 22nd 06 09:34 AM
RDO (Redemption Objects) with events in VB 6.0 [email protected] Add-ins for Outlook 1 October 13th 06 06:06 PM
Redemption Trapping a Condition or a Setting bobdydd Outlook - General Queries 3 June 2nd 06 02:55 PM
Redemption Trapping a Condition or a Setting bobdydd Outlook and VBA 3 June 2nd 06 02:55 PM


All times are GMT +1. The time now is 08:04 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-2025 Outlook Banter.
The comments are property of their posters.