Mensaje    Asunto: Codificación MIME Responder citando

Estoy haciendo el siguiente procedimiento para leer los correos de una cuenta POP3

Código:

void __fastcall TMainFrm::RetrieveExecute(TObject *Sender)
{
   if (!POP->Connected())
      {
       POP->Connect();
      }

  AnsiString LocalAttachmentfilename;
  AnsiString RecievedAttachmentfilename;
  AnsiString stTemp;
  int  intIndex;
  TListItem *li;

   stTemp = StatusBar1->Panels->Items[1]->Text;
   if (lvHeaders->Selected ==NULL)
    return;

   //initialise
   ShowBusy(true);
   Msg->Clear();
   Memo1->Clear();
   lvMessageParts->Items->Clear();
   From->Caption = "";
   Cc->Caption = "";
   Subject->Caption = "";
   Date->Caption = "";
   Receipt->Caption = "";
   Organization->Caption = "";
   Priority->Caption = "";
   pnlAttachments->Visible = false;

   //get message and put into MSG
   ShowStatus("Retrieving message " + lvHeaders->Selected->SubItems->Strings[3]  );
   int msgnum=lvHeaders->Selected->Index + 1;
   POP->Retrieve(msgnum, Msg);
   StatusBar1->Panels->Items[0]->Text = lvHeaders->Selected->SubItems->Strings[3];

   //Setup fields on screen from MSG
   From->Caption = Msg->From->Text;
   Recipients->Caption = Msg->Recipients->EMailAddresses;
   Cc->Caption = Msg->CCList->EMailAddresses;
   Subject->Caption = Msg->Subject;
   Date->Caption = FormatDateTime("dd mmm yyyy hh:mm:ss", Msg->Date);
   Receipt->Caption = Msg->ReceiptRecipient->Text;
   Organization->Caption = Msg->Organization;

   Priority->Caption = IntToStr((unsigned char)Msg->Priority + 1);


   //Setup attachments list
   ShowStatus("Decoding attachments (" + IntToStr(Msg->MessageParts->Count) + ")");
   Memo1->Lines->Clear();
   for (intIndex = 0; intIndex < (Msg->MessageParts->Count) ;intIndex++)
   {
         if (dynamic_cast<TIdAttachment*>(Msg->MessageParts->Items[intIndex]))

           { //general attachment
               pnlAttachments->Visible = true;
               li = lvMessageParts->Items->Add();
               li->ImageIndex = 8;
               RecievedAttachmentfilename= dynamic_cast<TIdAttachment*>(Msg->MessageParts->Items[intIndex])->FileName;

            TIdAttachment*e=dynamic_cast<TIdAttachment*>(Msg->MessageParts->Items[intIndex]);
               LocalAttachmentfilename=ExtractFilePath(ParamStr(0));
               LocalAttachmentfilename=LocalAttachmentfilename + "ATTACH\\";//add attach folder name to store locally in sub folder
               LocalAttachmentfilename=LocalAttachmentfilename + RecievedAttachmentfilename;
               li->Caption=LocalAttachmentfilename;
               if (e!=NULL)
               e->SaveToFile(LocalAttachmentfilename);
            }
         else
            {//body text
              if (dynamic_cast<TIdText*>(Msg->MessageParts->Items[intIndex] ))// then
            {
               String rutahtml = ExtractFilePath(Application->ExeName) + "tmp.mht";
               ::DeleteFile(  ((AnsiString)rutahtml).c_str()   );
               Msg->SaveToFile(rutahtml);
               Memo1->Lines->AddStrings(dynamic_cast<TIdText*>(Msg->MessageParts->Items[intIndex])->Body);
               this->WebBrowser1->Navigate(rutahtml);
               this->WebBrowser1->Refresh();
            }
            }

      }
   ShowStatus(stTemp);

   if (POP->Connected())
      {
       POP->Disconnect();
      }

   ShowBusy(false);

}


*nota el codigo es del ejemplo de Cbuilder4 de los componentes INDY ya que el codigo del CBuilder 5 no funciona en su totalidad.

cuando el correo se envia en texto plano, no hay problema en presentarlo en un TMemo, pero si el correo viene en formato HTML o MHT este ultimo pagina completa, no se presenta correctamente,

existe alguna manera de reconstruir el correo original, y mostrarlo un poco mas legible, si es html, mostrarlo en html o si es mht, mostrarlo en html

la opcion es relizar una decoficación tal y como lo hace el programa de OutLook para mostrar el correo correctamente.

o en su caso mostrarlo en algun componente de la paleta de Office2k
como es el caso de TOutLookApplication

Saludos
_________________
Cool