Save all incoming mail to DB

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

Save all incoming mail to DB
 
Andre Rossouw


Guest


Hi all,

I need to save all incoming mail to a DB. I have written it with Delphi 7 and using Add-in Express 2010.

Is there a event that fires so that I can be certain the mail would be save to the DB?
Currently I am using the NewMailEx event. It works fine on Outlook 2007, but in Outlook 2003 I have a problem that when I call GetItemFr omID, that mail is not available yet.

For example:

Procedure OutlookEventsNewMailEx(ASender: TObject;
const EntryIDCollection: WideString);
var
mi: MailItem;
begin
mi := MailItem(outlookApp.Session.GetItemFromId(EntryIdCollection, ''));
AddMailInboxLocal(mi); //Just adding the data to the DB, but I get an AV
end;


Also, is there another way of doing this? I have read the following about the lim itations of trying this. http://www.add-in-express.com/creating-addins-blog/2008/04/25/newmail-itemadd-outlook-events/.


Regards,

Andre
Posted 26 Oct, 2010 09:11:37 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hi Andre,

EntryIDCollection contains a set of EntryId values, not a single one. Please check http://msdn.microsoft.com/en-us/library/aa171304(office.11).aspx.

At http://www.eggheadcafe.com/software/aspnet/35240064/newmailex-only-provides-first-email-in-inbox.aspx:

If you are working with an Exchange account in cached mode, NewMailEx will
fire for every single item received, so you will see only one entry ID each
time. In online mode, it will return multiple items, but may skip a small
number under extremely heavy loads.


Also, see http://www.eggheadcafe.com/software/aspnet/32281795/problem-using-newmailex.aspx.

As far as I remeber that event should not fire for an e-mail that your Exchange receives while Outlook is down.

That is, in the generic case, you will have to scan all folders to get all new e-mails.


Andrei Smolin
Add-in Express Team Leader
Posted 26 Oct, 2010 10:51:50 Top
Andre Rossouw


Guest


Thanx for the info and prompt response Andrei. Will have a look at it.

Regards

Andre
Posted 27 Oct, 2010 01:55:46 Top