2012-07-03 105 views
2

我在下面的代码中遇到了问题,它指的是StoredPathName。由于Indy 10不使用StoredPathName,我不确定如何更改此代码以从V9调整到V10。下面的代码不是我自己写的,当谈到这种类型的代码时,我仍然是一个新手,所以我会很感激代码示例,展示如何尽可能地纠正问题。将Delphi Indy 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; 

同样的代码,另外一个位是... Connect(9000); 由于9000是不是允许的说法我只是把它改为Connect;这样可以吗?

+0

在印地如图9所示,参数为'连接()'是'ConnectTimeout'。在Indy 10,这是移动自己的财产。 –

回答

1

StoredPathName是从TIdMessagePart移到TIdAttachmentFile的属性。如果你改变代码在顶部进行类型转换,它应该都可以工作。

变化这样的:

with Msg.MessageParts[k] do 
    if Msg.messageParts[k] is TIdAttachmentFile then 

到:

if Msg.messageParts[k] is TIdAttachmentFile then 
    with TIdAttachmentFile(Msg.MessageParts[k]) do 
+0

是的,解决了这个问题。非常感谢。 – Col