New Items in the Send Mail Folder

Add-in Express™ Support Service
That's what is more important than anything else

New Items in the Send Mail Folder
How do I detect there are new email in the sent folder 
Julian Pointer


Guest


I need to save all sent emails, the way I do this in VB is below, I set an object to the sentmail foler items then on the additem event I call my save code, how can I do this in add-in-express?



Private WithEvents objSentItems As Items

sub init....

Dim NS As Outlook.NameSpace
Set NS = golApp.GetNamespace("MAPI")
Set objSentItems = NS.GetDefaultFolder(olFolderSentMail).Items

end

Private Sub objSentItems_ItemAdd(ByVal Item As Object)
do something....
end sub
Posted 09 May, 2005 00:56:42 Top
Dmitry Kostochko


Add-in Express team


Posts: 2806
Joined: 2004-04-05
Hi Julian,


uses Outlook2000;

type
  TAddInModule = class(TadxCOMAddInModule)
    procedure adxCOMAddInModuleAddInInitialize(Sender: TObject);
    procedure adxCOMAddInModuleAddInFinalize(Sender: TObject);
  private
    FItems: TItems;
    procedure DoItemAdd(ASender: TObject; const Item: IDispatch);
  protected
  public
  end;

...

procedure TAddInModule.adxCOMAddInModuleAddInInitialize(Sender: TObject);
begin
  FItems := TItems.Create(nil);
  FItems.ConnectTo(OutlookApp.GetNamespace('MAPI').GetDefaultFolder(olFolderSentMail).Items);
  FItems.OnItemAdd := DoItemAdd;
end;

procedure TAddInModule.adxCOMAddInModuleAddInFinalize(Sender: TObject);
begin
  if Assigned(FItems) then
    FItems.Free;
end;

procedure TAddInModule.DoItemAdd(ASender: TObject; const Item: IDispatch);
begin
  // do something
end;


Posted 09 May, 2005 06:49:21 Top
Johnny Bravenboer




Posts: 13
Joined: 2006-03-20
(Using Delphi 5 Professional)

Hi again,

I'm trying to automatically export email messages to *.msg files that are placed in the Sent Items folder (when a message has been successfully sent). For that I was trying to make use of the code presented in this thread and now I'm puzzled as I get this error:

Undeclared identifier: 'TItems'


What am I missing here?

I also noticed that is this code sample no parameters are sent to the 'DoItemAdd' procedure, so my question is what parameters should be sent?

Thanks and regards,

John... ;)
Posted 15 Apr, 2006 01:11:17 Top
Dmitry Kostochko


Add-in Express team


Posts: 2806
Joined: 2004-04-05
Hi John,

Office wrapper components are limited in Delphi 5. I.e. Delphi 5 Outlook2000 has all interface descriptions but doesn't have classes. Do you have a newer version of Delphi (6, 7, 2005, 2006)?

Posted 17 Apr, 2006 07:37:39 Top
Johnny Bravenboer




Posts: 13
Joined: 2006-03-20
Hi Dmitry,

Before I start switching to another Delphi version, isn't there some kind of work-around that will work with Delphi 5 Professional?

What I actually need is for the user to be able to "activate" a button in a "new message" window that will put the "saving-to-file" on hold until the message is actually sent (placed in the "sent items" folder).

So what should happen is:

- The user opens a new message
- The user "activates" the (Inspector Bar) "Save To File" button
- The user types the message
- The user clicks the (Native Outlook) "Send" button
- The message is being sent
- After the message has been actually sent, the message will be automatically saved to a *.msg file.

Btw, the only "newer" versions I have of Delphi are Delphi 7 Personal and Delphi 2005 personal, of which I'm not sure if they can work with the database engine I'm using in my project.

Thanks and regards,

John... ;)
Posted 17 Apr, 2006 10:36:07 Top
Dmitry Kostochko


Add-in Express team


Posts: 2806
Joined: 2004-04-05
Hi John,

Before I start switching to another Delphi version, isn't there some kind of work-around that will work with Delphi 5 Professional?


Yes, I think there is. You can try to import the Outlook type library, then Delphi will try to create the TItems class automatically. If it fails, you can create this class manually.

Posted 17 Apr, 2006 11:49:04 Top
Johnny Bravenboer




Posts: 13
Joined: 2006-03-20
Yes, I think there is. You can try to import the Outlook type library, then Delphi will try to create the TItems class automatically.


Hi Dmitry,

I've tried what you've suggested, but it does not seem to work as TItems does not appear to be part of the Microsoft Outlook 11.0 Object Library (Version 9.2) that I have on this system?

Or am I still missing something here?
This would be the ActiveX library you are refering too..?

Regards,

John... ;)
Posted 17 Apr, 2006 21:30:48 Top
Dmitry Kostochko


Add-in Express team


Posts: 2806
Joined: 2004-04-05
Hi John,

Please contact me by email, I will try to help.

Posted 18 Apr, 2006 07:28:36 Top
Johnny Bravenboer




Posts: 13
Joined: 2006-03-20
you can create this class manually


Hi Dmitry,

THANK YOU, THANK YOU, THANK YOU!! :)

The TItems class you've sent me worked perfectly and I seriously doubt I've would have been able to "create this class manually".

After adding the TItems class to my Delphi 5 project, the above source code compiled perfectly and functions as intended, which is in one word:

GREAT!!

Thanks you very much for the great support :D

Regards,

John... ;)
Posted 19 Apr, 2006 20:54:12 Top