• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 210
  • Last Modified:

Delphi: What is a simple DB to use for an email program?

I have decided to write myself a simple POP3 Email Client based on some freeware components I found. There are a few simple features I would like that MS Outlook doesnt have, and I have decided the best way to get them is to write them myself. I'm not trying to take on Microsoft or change the world, I just have a few simple, specific needs that I know I'm capable of writing.

I'm not sure what is the best way to store the messages once they are downloaded, and this is my question.

I could store them in folders as .eml files. this approach would be simple, but I can see big speed problems when populating the inbox - ie having to open hundreds of files to get the info.

I use a MySQL database for everything else I do, but this needs to be installed, and the tables would need to be loaded via an SQL file. I was hoping to use a DB that can install itself easily via my app so I can share my program with friends.

The DB needs only be single user, needs to be installable via the app, and it would be preferable if it takes SQL commands as I am familiar with these. I also want to avoid the Borland Database Engine if possible, I have had grief with this in the past.

Is using MS Access via the Access Runtimes a viable option? I understand these are a free component that allows your app to use a .mdb file but the user doesn't need MS Access installed on their machine. If this is a good option, how would I go about connecting to an Access database via Delphi (pref without BDE). Thanks in advance.
  • 3
  • 2
  • 2
  • +3
2 Solutions
You may use firebird avoiding BDE via Interbase components (Delphi VCL). But firebird must to be installed before using it ....
Firebird- that I have is 3.76 MB


You may use MS Access database avoiding BDE via ADO. But it must to be installed MS Data Access Components (MSDAC). It is provided as MDAC_TYP.EXE (version 2.8 that I have is 5.3 MB)
Wim ten BrinkCommented:
Using MS Access through the ADO components would be a good solution. But I have done something similar too and just stored the emails in an XML file. But if you receive lots of emails, your database will become huge.
In the end, I just decided to store each email as a separate *.eml file and used an XML file as index for all emails. But I also filter the emails and divide them over multiple folders. The XML file would just contain a summary of the email contents. (Sender, subject, etc.)

But Access requires the user to have ADO (not specifically Access) to be installed on their system. Especially on W2K and before, ADO would require a separate installation. (But is free.)
InterBase is an option too but it's a bit troublesome to install and maintain InterBase for the generic user. Most developers can handle it but most users don't.
FlashFiler is an interesting Client/Server database and can be found at http://sourceforge.net/projects/tpflashfiler/ FlashFiler is especially useful if you want multiple users to connect to a centralized mailbox. ;-) FlashFiler doesn't require any additional files either. You could have everything within a single executable.
But I mentioned XML, didn't I? If you want to keep it real simple, use just an XML file. It's main advantage is that combined with an XSLT stylesheet you could easily display the XML file in a webbrowser as HTML. And within Delphi an XML file is just an array of array within arrays...
If wanna get on a relational DB, Firebird offer the
possibility of using a embedded server.
A embedded server is just a FB server encapsulated
on a single DLL you could run from your program.
Just local access, no network issues and you could
use the dll also as client for a remote server.
See www.firebirdsql.org or www.ibphoenix.com for
articles and/or details about this.

[]s Delphian
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

definitely FireBird Embeded .. no instalation required, small footprint, powerful RDBMS
harveykaneAuthor Commented:
OK, Thanks for the comments so far, I will look into all options and post points accordingly :)
Wayne BarronCommented:
If you decided to go with the Access Database.
It will get HUGE, but Access Database's are designed to grow to
Around 2 - 3 Gigs in Size. I cannot remember the exact number.
As I had ask the question in a Microsoft Access Newsgroup once before.

So as long as you are not plaining on keeping the messages forever.
Then Access could be a good Fast way of going about you e-mail project.

( As I doubt that you would allow your Inbox or Extra Folder to grow that huge anyway :-) ) But if you are plaining on using Access.
Then I would also do a Backup on it as well. This just in case of Corruption of the Database. Maybe set it to do the Backup on "Every Close of the Program" this will save you a lot of troublesome times...
Believe me, I lost my Outlook InBox DB. and it was not pretty.
Business e-mails and everything down the drain.

Create a good program, Make it do "OnClose - DB Saves"

Take Care HTH

Wim ten BrinkCommented:
I did create my own POP3 mailreader once and to keep the database fast, I didn't store the emails in the database, because I receive about 100+ emails every day with sizes varying from a few KB to several MB's. What I did was simple. I created a folder where the emails would be stored. But because this too would become quite large, I would create a subfolder every day, with the date (YYYY-MM-DD) as folder name. In these folders I stored the raw emails and all I stored in the database was the header information for every email. Sender, recipients, subject, date etc. are stored in in an SQL Server database with the filename of the raw email allowing me to do some quick searches for specific mails and also allows me to define special mail folders. I wouldn't move them physically in my folders.
This is the approach of PMMail also, but they allow search and
filters based on message text.
There is not a central DB but some texts file with the headers.
But the app slow down with many messages in the same folder
(which occur with my mail lists).
But... SQL Server? There is nothing more expensive ? ;-))))))
(just a kidding...)
You could store the msg within a blob (in the case, a image field)
and allow text search in the blob, without the mess with transliteration
and charsets.
The file will grow, but is better (and faster) than seaching files - which
tends to slow

I'd go for Firebird embedded.
harveykaneAuthor Commented:
Thanks for the comments everyone.

I ended up using Firebird Embedded as per Delphian's suggestion - OMFG what a great solution. Full functionality contained within a single DLL, and if I wanted to go for multi-user later on, just install the Firebird server and change a couple of lines of code.

I'm not sure if I will store message itself in the DB, or in the eml file yet. I will probably store the message body text in the DB so it's searchable, and the rest of the message including source and attachments in dated folders as per workshop_alex's suggestion.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now