Reputation: 33
I'm having trouble with the code below that refers to StoredPathName
. As Indy 10 doesn't use StoredPathName
, I'm not sure how to change this code to adjust from V9 to V10. The code below wasn't written by me and I'm still a newbie when it comes to this type of code, so I'd appreciate a code example showing how to correct the problem if possible.
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;
Also one other bit of code was... Connect(9000);
Since 9000 wasn't an allowed argument I just changed it to Connect;
Is that OK?
Upvotes: 2
Views: 484
Reputation: 860
StoredPathName is a property that was moved from TIdMessagePart to TIdAttachmentFile. If you change the code to do a type cast at the top it should all work.
change this:
with Msg.MessageParts[k] do
if Msg.messageParts[k] is TIdAttachmentFile then
to:
if Msg.messageParts[k] is TIdAttachmentFile then
with TIdAttachmentFile(Msg.MessageParts[k]) do
Upvotes: 1