Outlook - OnReply, OnAllReply, OnForward
how to get the email events of Reply, ReplyAll and Forward
|
Ralf Garbe
Posts: 20
Joined: 2014-11-22
|
Hi,
I need to react on emails when the user replies or forwards an email.
In the past I had found code here, but I have the impression that in some cases (for instance when moving emails to other folders), and only sometimes, Outlook crashes.
The code I used so far was as follows:
procedure TAddInModule.adxOutlookAppEvents1ExplorerSelectionChange(Sender: TObject);
var
sel : Selection;
item: _MailItem;
xClass, xRel: string;
begin
{
try
sel := OutlookApp.ActiveExplorer.Selection;
except
end;
if Assigned(sel) and (sel.Count > 0) then begin
sel.Item(1).QueryInterface(IID__MailItem, item);
if Assigned(item) then begin
if Assigned(MItem) then MItem.Disconnect(); MItem := TMailItem.Create(nil);
MItem.OnReply := DoOnReply;
MItem.OnReplyAll := DoOnReplyAll;
MItem.OnForward := DoOnForward;
MItem.ConnectTo(item);
item := nil;
end;
end;
sel := nil;
}
end;
Hope you can help,
Thanks,
Ralf |
|
Posted 22 Nov, 2014 14:36:11
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18791
Joined: 2006-05-11
|
|
Posted 24 Nov, 2014 03:51:32
|
|
Top
|
|
Ralf Garbe
Posts: 20
Joined: 2014-11-22
|
Hello Andrei,
thanks for the answer, however I'm not sure how to do the suggested.
The adxOutlookAppEvents component does not provide the BeforeItemMove event. I just found the events
- OnExplorerBeforeItemCopy, OnExplorerBeforeItemCut and OnExplorerBeforeItemPaste.
Thanks for your help,
Regards,
Ralf |
|
Posted 26 Nov, 2014 14:39:54
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18791
Joined: 2006-05-11
|
|
Posted 27 Nov, 2014 02:18:39
|
|
Top
|
|
Ralf Garbe
Posts: 20
Joined: 2014-11-22
|
Hello Andrei,
thanks for the suggestion, however the suggested creates more problems.
The 2010 TLB does not support TMailItem, but MailItem, which does not support any methods.
Could you consider once more how to react on the Reply, ReplyAll and Forward events to an email.
Thanks,
Ralf |
|
Posted 27 Nov, 2014 15:53:26
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18791
Joined: 2006-05-11
|
Ralf,
You need to use TMailItem from the Office 2000 TLB. You need to use the Office 2007-2013 TLB to connect to the BeforeItemMove event only.
Do I answer your questions?
Andrei Smolin
Add-in Express Team Leader |
|
Posted 28 Nov, 2014 03:21:42
|
|
Top
|
|
Ralf Garbe
Posts: 20
Joined: 2014-11-22
|
Hello Andrei,
I'm not good in COM programming, that's why I use Add-in Express.
I was able to add to the code below, but it does not help me, nor does it provide me the ability to link to the BeforeItemMove event.
Could you provide me an example in the above code which links to the BeforeItemMove event, and show me how the BeforeItemMove event needs to be defined?
Thanks for your help,
Ralf
procedure TAddInModule.adxOutlookAppEvents1ExplorerSelectionChange(Sender: TObject);
var
ol2010: Outlook2010._Application;
aFolder: Outlook2010.Folder;
i: integer;
begin
ol2010:= self.OutlookApp.Application as Outlook2010._Application;
for i := 1 to ol2010.Session.Stores.Count do
showMessage('Store ' + intToStr(i) + ': ' + ol2010.Session.Stores.Item(i).DisplayName);
aFolder := ol2010.Session.Folders.Item(1);
for I := 1 to aFolder.Items.Count do
showMessage('Folder Name: ' + aFolder.Folders.Item(i).Name);
end; |
|
Posted 29 Nov, 2014 17:10:40
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18791
Joined: 2006-05-11
|
|
Posted 01 Dec, 2014 10:11:25
|
|
Top
|
|
Ralf Garbe
Posts: 20
Joined: 2014-11-22
|
Anderei,
many thanks!
Even I could integrate this in my code :)
For future versions of Add-In Exress
You might want to consider adding the events of OnReply, OnAllReply, OnForward in future version of Add-In Express.
Best Regards,
Ralf |
|
Posted 01 Dec, 2014 14:30:25
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18791
Joined: 2006-05-11
|
Thank you for the suggestion!
Andrei Smolin
Add-in Express Team Leader |
|
Posted 02 Dec, 2014 09:02:03
|
|
Top
|
|