我一直在使用 Indy 发送和接收电子邮件。现在我有一个 ssl 邮件服务器,但我还没有从电子邮件中获取附件?请帮我....
Memo1.Clear;
POP3.ConnectTimeout := 20000;
if POP3.Connected then
POP3.Disconnect;
POP3.Host := '*******';
POP3.Port := 995;
POP3.Username := '*******';
POP3.Password := '*******';
SSLIOHandler.Host := POP3.Host;
SSLIOHandler.Port := POP3.Port;
POP3.IOHandler := SSLIOHandler;
POP3.UseTLS := utUseImplicitTLS
try
POP3.Connect;
except
Memo1.Text := Memo1.Text + 'Can not connect to server' + #13#10;
Memo1.Text := Memo1.Text + '==========' + #13#10;
end;
for i := 1 to POP3.CheckMessages do
begin
Msg.Clear;
POP3.RetrieveHeader(i, Msg)
Memo1.Text := Memo1.Text + 'Subject: ' + Msg.Subject + #13#10;
Memo1.Text := Memo1.Text + 'AttachmentCount: ' + IntToStr(Msg.MessageParts.AttachmentCount) + #13#10;
Memo1.Text := Memo1.Text + 'MessagePartsCount: ' + IntToStr(Msg.MessageParts.Count) + #13#10;
Memo1.Text := Memo1.Text + '==========' + #13#10;
for j := 0 to Msg.MessageParts.Count do
begin
if (Msg.MessageParts.Items[j] is TIdAttachmentFile) then
begin
//My Code
end;
end;
end;
POP3.Disconnect;
Memo1.Text := Memo1.Text + 'End of conecction' + #13#10;