我使用TMimeMess来解码我的SMTP服务器的传入电子邮件
在Synapse上.
在Synapse上.
我发现用于解码50MB的MIME消息(简单的文本
附件),TMimeMess使用了600-800MB的内存.
解码码在这里:
FMimeMsg.Header.DecodeHeaders(FMimeMsg.MessagePart.Lines); FMimeMsg.MessagePart.DecomposeParts; ExtractPartsFromMess(FMimeMsg.MessagePart); ... procedure ExtractPartsFromMess(AMimePart: TMimePart); var i: integer; begin if AMimePart.GetSubPartCount = 0 then Begin if (AMimePart.PrimaryCode = MP_TEXT) then Begin AMimePart.DecodePart; FBody.Add(string(ReadStrFromStream(AMimePart.DecodedLines,AMimePart.DecodedLines.Size))); end else if (AMimePart.PrimaryCode = MP_BINARY) then Begin if AMimePart.FileName <> '' then Begin AMimePart.DecodePart; AMimePart.DecodedLines.SaveToFile(FPathToIncomingFolder+AMimePart.FileName); end; end; end else Begin for i:=0 to AMimePart.GetSubPartCount-1 do Begin ExtractPartsFromMess(AMimePart.GetSubPart(i)); end; end; end;
谢谢.