使用imap仅从Gmail“已发送的项目”下载一些电子邮件标头

时间:2013-06-29 07:04:01

标签: delphi gmail imap

关于我earlier question关于访问“已发送的项目”的问题。 Gmail中的文件夹,接受的答案中显示的代码下载所有文件夹中的邮件标题,使用UIDRetrieveAllEnvelopes执行此操作。我将所有标题下载完毕后对其进行过滤。

有没有办法只下载 当天发送的消息(即下载前过滤)?

2 个答案:

答案 0 :(得分:2)

无法仅检索特定文件夹中某一天的消息。

IMAP方式是缓存消息/信封,仅检索最近/新消息。 请查看TIdIMAP4.StatusMailboxTIdIMAP4.RetrieveFlags以查看客户端的新消息,并仅下载这些消息/敌人。

可能的标志是

  TIdMessageFlags =
  ( mfAnswered, //Message has been answered.
    mfFlagged, //Message is "flagged" for urgent/special attention.
    mfDeleted, //Message is "deleted" for removal by later EXPUNGE.
    mfDraft, //Message has not completed composition (marked as a draft).
    mfSeen, //Message has been read.
    mfRecent ); //Message is "recently" arrived in this mailbox.

答案 1 :(得分:0)

我似乎找到了一种方式

 today:= datetostr (date);
 with imap do
  begin
   Username:= 'whatever@gmail.com';
   Password:= ....;
   Connect;
   if SelectMailBox('[Gmail]/sent items') then
    begin
     i:= MailBox.TotalMsgs;
     retrieve (i, email);
     while datetostr (email.date) = today do
      begin
       lb.items.add (email.subject + ' ' + datetostr (email.date));
       dec (i);
       retrieve (i, email)
      end 
    end;
   Disconnect;
  end;