Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


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

Posted on 2004-09-25
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 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...

Accepted Solution

Delphian earned 300 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 www.firebirdsql.org or www.ibphoenix.com for
articles and/or details about this.

[]s Delphian
Technology Partners: 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!

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 31

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 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

618 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