Luigi
Luigi

Reputation: 1

Using Delphi to read emails subfolders in InBox on Thunderbird

I need to read emails from Thunderbird email client for all accounts Inbox and all his subfolders.

How I change the code to read all email from every subfolders?

Thanks

With this code (get from examples by Jedy libraries) I read emails only from default InBox Folder:

DownloadsListView.Items.Clear;
JvMail1.LogonOptions := [JvMail.loNewSession, JvMail.loDownloadMail];
JvMail1.LogOn;
try
  b := JvMail1.FindFirstMail;
  while b do
  begin
    JvMail1.ReadOptions := [roFifo, roHeaderOnly, roPeek];
    JvMail1.ReadMail;
    with DownloadsListView.Items.Add do
    begin
      Caption := JvMail1.Subject;
      SubItems.Add(JvMail1.ReadedMail.RecipientName);
      SubItems.Add(DateTimeToStr(JvMail1.ReadedMail.DateReceived));
    end;
    b := JvMail1.FindNextMail;
  end;
finally
  JvMail1.LogOff;
  JvMail1.Clear;
  DownloadsListView.BringToFront;
end;

Upvotes: 0

Views: 480

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 598134

TJvMail is a wrapper for SimpleMAPI, which has no concept of subfolders, and can only access a profile's inbox. You would need to use CDO or Extended MAPI to have full access to a profile's subfolders, but TJvMail does not support that.

Differences between CDO, Simple MAPI, and Extended MAPI

Alternatively, use the IMAP protocol (such as via Indy's TIdIMAP4 component) to access the email server directly, instead of accessing the user's local email client.

Upvotes: 2

Related Questions