开发者

Indy TIdImap4.UIDRetrieve method!

Here is my little code:

curMessage:TIdMessage;
tidImap: TIdIMAP4;
...
tidImap.UIDRetrieve('123', curMessage);

That works fine! Now when i try to read

curMessage.Body

Then开发者_如何学Go it is empty sometimes. I've understand that it is empty when message IsMsgSinglePartMime is False. So then i can't read message's body from Body property.

I've searched in curMessage's every property, but nowhere could i found the body text. What makes it even more odd, is that when i save curMessage

curMessage.Savefile('...');

then i can see all the body there.

I don't want to make another request to fetch for the body (eg UIDRetrieveText(2)) because i understand that the body data is there somewhere, i just could not find it or is Savefile/SaveStream making some internal requests to server?

Thank you guys in advance!


You need to be checking TIdMessage.MessageParts.

var
  Msg: TIdMessage;
  i: Integer;
begin
  // Code to retrieve message from server
  for i := to Msg.MessageParts.Count - 1 do
  begin
    if (Msg.MessageParts.Items[i] is TIdAttachment) then
      // Handle attachment
    else
    begin
      if Msg.MessageParts.Items[i] is TIdText then
        HandleText(TIdText(Msg.MessageParts.Items[i]).Body);
    end;
  end;
end;

In Indy 10, TIdMessageParts has been moved into it's own unit, so you may have to add IdMessageParts to your uses clause.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜