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

Posted on 2004-09-25
Last Modified: 2010-04-05
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.
Question by:harveykane
  • 3
  • 2
  • 2
  • +3
LVL 12

Expert Comment

ID: 12152174
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)
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12152631
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 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...

Accepted Solution

Delphian earned 75 total points
ID: 12153747
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 or for
articles and/or details about this.

[]s Delphian
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

LVL 12

Expert Comment

ID: 12158478
definitely FireBird Embeded .. no instalation required, small footprint, powerful RDBMS

Author Comment

ID: 12163949
OK, Thanks for the comments so far, I will look into all options and post points accordingly :)
LVL 30

Expert Comment

by:Wayne Barron
ID: 12256439
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

LVL 17

Assisted Solution

by:Wim ten Brink
Wim ten Brink earned 50 total points
ID: 12261985
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.

Expert Comment

ID: 12277094
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...)

Expert Comment

ID: 12299322
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.

Author Comment

ID: 12301599
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question