How to read the subject of mail in OnNewMail event
How to read the subject of mail in OnNewMail event
|
Giuseppe Borgobello
Posts: 5
Joined: 2006-09-14
|
Hi,
I don't find the way for read the subject and other property in OnNewMail event for the mail receipt.
I have tryed by :
procedure TAddInModule.OEventNewMail(Sender: TObject);
var
ml_subject ; String;
begin
ml_subject := (Sender as adxOLMailItem).Subject;
but the type of Sender is not adxOLMailItem
I need help :idea: :D
Thanks
Giuseppe |
|
Posted 14 Sep, 2006 09:16:08
|
|
Top
|
|
Giuseppe Borgobello
Posts: 5
Joined: 2006-09-14
|
Hai Hai,
in the previous thread Dmitry says that OnNewMail event fired when one or more new e-mail messages get into the Inbox .... while I believed fired for every new mail message.
My problem is manage the subject for all new mail, one by one , but not with OnNewMailEx (my reader is Outlook 2000).
Some idea ?
Thanks
Giuseppe
|
|
Posted 15 Sep, 2006 02:47:34
|
|
Top
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2880
Joined: 2004-04-05
|
Hi Giuseppe,
I would recommend handling the OnItemAdd event of the Inbox folder. In this case you will get the added item as a parameter.
See the Outlook Folder Items Events demo project.
|
|
Posted 15 Sep, 2006 06:15:34
|
|
Top
|
|
Giuseppe Borgobello
Posts: 5
Joined: 2006-09-14
|
Hi Dmitry,
excuse me, but I do not understand well.
I have tried the example that you have indicated to me, but when I receive more email, the event fired only one time, and not one by one for the single message.
For courtesy, you could make a simple example complete, that it visualizes the subject of every message in arrival?
Many Thanks
Giuseppe
|
|
Posted 15 Sep, 2006 09:06:10
|
|
Top
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2880
Joined: 2004-04-05
|
Hi Giuseppe,
Please contact me directly by email, I will try to create an example for you.
|
|
Posted 18 Sep, 2006 05:24:11
|
|
Top
|
|
Joshua Bernulli
Posts: 5
Joined: 2006-10-20
|
I'd also like to have an example of processing only new received mails if possible... |
|
Posted 16 Nov, 2006 23:11:33
|
|
Top
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2880
Joined: 2004-04-05
|
Hi Joshua,
See the code below:
uses {...,} Outlook2000;
type
//...
TAddInModule = class(TadxCOMAddInModule)
procedure adxCOMAddInModuleAddInInitialize(Sender: TObject);
procedure adxCOMAddInModuleAddInFinalize(Sender: TObject);
private
FItems: TItems;
protected
procedure DoItemAdd(ASender: TObject; const Item: IDispatch);
public
end;
implementation
{$R *.dfm}
procedure TAddInModule.adxCOMAddInModuleAddInInitialize(Sender: TObject);
var
IFolderInbox: MAPIFolder;
begin
FItems := nil;
if Assigned(OutlookApp) then begin
IFolderInbox := OutlookApp.GetNamespace('MAPI').GetDefaultFolder(olFolderInbox);
if Assigned(IFolderInbox) then
try
FItems := TItems.Create(nil);
FItems.ConnectTo(IFolderInbox.Items);
FItems.OnItemAdd := DoItemAdd;
finally
IFolderInbox := nil;
end;
end;
end;
procedure TAddInModule.adxCOMAddInModuleAddInFinalize(Sender: TObject);
begin
OutlookApp.OnNewMail := nil;
if Assigned(FItems) then
FItems.Disconnect;
end;
procedure TAddInModule.DoItemAdd(ASender: TObject; const Item: IDispatch);
var
IMail: MailItem;
begin
if Assigned(Item) then begin
Item.QueryInterface(IID__MailItem, IMail);
if Assigned(IMail) then
try
if IMail.UnRead then begin
//
// TODO (check the ReceivedTime property)
//
end;
finally
IMail := nil;
end;
end;
end;
|
|
Posted 17 Nov, 2006 08:13:03
|
|
Top
|
|
Joshua Bernulli
Posts: 5
Joined: 2006-10-20
|
|
Posted 18 Nov, 2006 04:08:36
|
|
Top
|
|