Make up the lack of IDPOP3 is only the processing of this part.

zhaozj2021-02-16  185

Subject is usually the following form when receiving some emails such as 163.com.

=? GB2312? B? Z290B21VYMLSZQ ==? =

This translation is Pic Test

I only need a function to handle it! INDY is no longer slander..

// iDPOP3 is missing only this part of the processing. Subject

// this function by Chris G München ther and Sergio Kesslerfunction ConvertCharSet (const Line: string): string; var strToDecode, RestBefore, RestAfter, strActual, decoded: string; iLast, iFirst, eFirst, i: integer; Encoding, c: char B64DECode: TBase64Decodingstream; dest: tmemorystream; begin stratactual: = line;

IFirst: = POS ('=?', stractual); while (iFirst> 0) Do Begin RESTBEFORE: = COPY (Stractual, 1, IFirst-1); startecode: = Copy (Stractual, IFirst 2, Length (Stractual) Efirst: = POS ('?', Strtodecode); if efirst> 0 THEN Encoding: = Uppercase (StrtODECode [Efirst 1]) [1]; delete, 1, efirst 2); // remove Until? q? or? b? Inclusive ilth: = POS ('? =', strtodecode); if Ilast> 0 Then Begin Restafter: = Copy (StrtODECode, ILAST 2, Length (strtodecode)); delete (Strtodecode, Ilast Length (strtodecode); // remove the? = and the rest

strActual: = RestBefore RestAfter; if Encoding = 'Q' then begin strActual: = RestBefore sak_QuotedPrintableDecode (PChar (strToDecode)) RestAfter; end else if Encoding = 'B' then begin Dest: = TMemoryStream.Create;

B64DECode: = TBase64DecodingStream.create (DEST); B64Decode.write (Pointer (strtodecode); b64decode.free;

DEST.PSITION: = 0; for i: = 1 to dest.size do beg dest.read (c, 1); decoded: = decoded C; end; dest.free; stratac: = restbefore Decoded Restafter; End; IFirst: = POS ('=?', stratual); ELSE IFIRST: = 0; ELSE IFIRST: = 0; END; Result: = streaction;

转载请注明原文地址:https://www.9cbs.com/read-8522.html

New Post(0)