将Delphi Indy v9代码转换为v10
下面的代码引用了将Delphi Indy v9代码转换为v10,delphi,email,indy10,Delphi,Email,Indy10,下面的代码引用了StoredPathName,我遇到了问题。由于Indy 10不使用StoredPathName,我不知道如何更改此代码以从V9调整到V10。下面的代码不是我写的,对于这种类型的代码,我还是一个新手,所以如果可能的话,我希望能提供一个代码示例来说明如何纠正这个问题 vlist:TStringList; ... for j:=numEmails downto 1 do begin Msg.Clear; Retrieve(j,Msg); for k:=
StoredPathName
,我遇到了问题。由于Indy 10不使用StoredPathName
,我不知道如何更改此代码以从V9调整到V10。下面的代码不是我写的,对于这种类型的代码,我还是一个新手,所以如果可能的话,我希望能提供一个代码示例来说明如何纠正这个问题
vlist:TStringList;
...
for j:=numEmails downto 1 do
begin
Msg.Clear;
Retrieve(j,Msg);
for k:=0 to Msg.MessageParts.Count-1 do
with Msg.MessageParts[k] do
if Msg.messageParts[k] is TIdAttachmentFile then
begin
//Get the name of the file that was sent.
aname := TIdAttachmentFile(Msg.MessageParts[k]).FileName;
if SameText(aname,ExtractFilename(PacketFilename))
and FileExists(Longfilename(StoredPathName)) then
begin
//Read attachment and do call-back if defined.
vlist.LoadfromFile(LongFilename(StoredPathName));
if assigned(OnReceive) then
OnReceive;
end
end;
end;
Disconnect;
except
on E:Exception do
result := E.Message;
end;
还有一段代码是<代码>连接(9000)代码>
因为9000不是一个允许的参数,我只是将它改为
Connect代码>可以吗?StoredPathName是一个已从TIdMessagePart移动到TIdAttachmentFile的属性。如果您将代码更改为在顶部执行类型转换,那么所有这些都应该可以工作
更改此项:
with Msg.MessageParts[k] do
if Msg.messageParts[k] is TIdAttachmentFile then
致:
在Indy 9中,Connect()
的参数是ConnectTimeout
。在印地10号,它被移到了自己的土地上。
if Msg.messageParts[k] is TIdAttachmentFile then
with TIdAttachmentFile(Msg.MessageParts[k]) do