POP3 계정에서 메일을 검색하는 데 사용하는 다음 코드가 있습니다. 대부분의 경우 잘 작동하지만 시간이 지남에 따라 시체를 검색하지 않는 메일이 있습니다. IdMessage.MessageParts.Count를 테스트하면 0이라고 표시됩니다. 다른 메일 클라이언트를 사용하여 메일을 검색하면 문제가 없습니다. 양식에 TIdPOP3 및 TIdMessage 구성 요소가 있습니다. 확인 표시가있는 메일이있을 수 있으므로 연결에 문제가 없습니다.Indy가 내 메일 함의 일부를 검색하지 않는 이유
메일이 올바르지 않거나 그렇지 않은 시스템을 알아낼 수 없습니다. 그러나 하나가있을 수 있습니다. 델파이 XE3 사용하고 인디 레미 Lebeau의 조언과 나는 아래의 코드로 결국 웹 검색으로 버전 10.5.9.0
procedure TfrmJsMailCollect.lstMailsClick(Sender: TObject);
var
MailBody: string;
intIndex: integer;
begin
if (lstMails.Items.Count = 0) or (lstMails.SelCount = 0) then
Exit;
MailBody := '';
try
begin
mmoBody.Clear;
lstMails.Selected.SubItems.Strings[0];
lstMails.Selected.ImageIndex := 4;
conPOP3.Retrieve(lstMails.Selected.Index + 1, IdMessage);
for intIndex := 0 To Pred(IdMessage.MessageParts.Count) do
begin
if (IdMessage.MessageParts.Items[intIndex] is TIdAttachmentFile) then
begin // Attachments are skipped
end
else
begin // body text
if Pos('text/plain', IdMessage.MessageParts.Items[intIndex].ContentType) <> 0 then
begin
if TIdText(IdMessage.MessageParts.Items[intIndex]).Body.Text <> '' then
begin
MailBody := MailBody + TIdText(IdMessage.MessageParts.Items[intIndex]).Body.Text;
mmoBody.Lines.Add(MailBody);
MemoValidate;
end;
end;
end;
end;
end;
mmoBody.CaretPos.SetLocation(0, 0);
Application.ProcessMessages;
except
Logfile.Error('F_JsMailCollect.lstMailsClick - ' + cxGetResourceString(@sLangPop3ErrorReading));
end;
end;
입니다. 이것은 지금 당장은 트릭이지만, 나는 그것을 향상 시켜서 나의 양식에있는 메모가 모든 사람들이 읽을 수있는 멋진 메시지만을 보여줄 수 있도록하고 싶습니다. 그러나 나중에 나올 수 있습니다.
procedure TfrmJsMailCollect.lstMailsClick(Sender: TObject);
var
MailBody: string;
i: integer;
ContentType: string;
begin
if (lstMails.Items.Count = 0) or (lstMails.SelCount = 0) then
Exit;
try
MailBody := '';
mmoBody.Clear;
lstMails.Selected.SubItems.Strings[0];
lstMails.Selected.ImageIndex := 4;
conPOP3.Retrieve(lstMails.Selected.Index + 1, IdMessage);
ContentType := IdMessage.ContentType;
case PosInStrArray(ContentType, ['multipart/mixed', 'multipart/alternative', 'text/html', 'text/plain'], False) of
0: begin { multipart/mixed }
for i := 0 To Pred(IdMessage.MessageParts.Count) do
begin
if TIdText(IdMessage.MessageParts.Items[i]).Body.Text <> '' then
begin
MailBody := MailBody + TIdText(IdMessage.MessageParts.Items[i]).Body.Text;
mmoBody.Lines.Add(MailBody);
MemoValidate;
end;
end;
end;
1: begin { multipart/alternative }
for i := 0 To Pred(IdMessage.MessageParts.Count) do
begin
if TIdText(IdMessage.MessageParts.Items[i]).Body.Text <> '' then
begin
MailBody := MailBody + TIdText(IdMessage.MessageParts.Items[i]).Body.Text;
mmoBody.Lines.Add(MailBody);
MemoValidate;
end;
end;
end;
2: begin { text/html }
mmoBody.Lines := IdMessage.Body;
MemoValidate;
end;
3: begin { text/plain }
mmoBody.Lines := IdMessage.Body;
MemoValidate;
end;
else
// nothing supported to display...
end;
mmoBody.CaretPos.SetLocation(0, 0);
Application.ProcessMessages;
except
Logfile.Error('F_JsMailCollect.lstMailsClick - ' + cxGetResourceString(@sLangPop3ErrorReading));
end;
end;
확인 - 누락 된 부분을 찾을 수 있는지 살펴 보려고합니다. – OZ8HP