加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

如何使用带文件附件的indy 10和delphi 7接收电子邮件?

发布时间:2020-12-15 09:31:05 所属栏目:大数据 来源:网络整理
导读:如何使用带文件附件的indy 10和delphi 7接收电子邮件? 解决方法 这是Indy 10的代码. ‘Files’是一个字符串列表,其中包含已下载的附件列表 – 我对附件感兴趣,而不是字母本身. with IdPop31 dobegin ConnectTimeout := 5000; Connect; try files.Clear; for
如何使用带文件附件的indy 10和delphi 7接收电子邮件?

解决方法

这是Indy 10的代码. ‘Files’是一个字符串列表,其中包含已下载的附件列表 – 我对附件感兴趣,而不是字母本身.

with IdPop31 do
begin
  ConnectTimeout := 5000;
  Connect;
  try
    files.Clear;
    for i := 1 to checkmessages do
    begin
      msg.clear;
      flag := false;
      if retrieve (i,msg) then
      begin
        for j := 0 to msg.MessageParts.Count-1 do
        begin
          if msg.MessageParts[j] is TIdAttachment then
          begin
            with TIdAttachment(msg.MessageParts[j]) do
            begin
              s := IncludeTrailingPathDelimiter(mydir) + ExtractFileName(FileName);
              log ('Downloaded ' + s);
              if not FileExists(s) then
              begin
                SaveToFile(s);
                files.Add(s);
              end;
             end;
            end;
            flag := true;
          end;
        end;
      end;
      if flag then Delete(i);  // remove the email from the server
    end;
  finally
    Disconnect;
  end
end;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读