title: Send email with attachment in Delphi
body: <p>How do I send an attachment in an HTML formatted email?</p>
  
  <p>I managed to send an email using stmp.gmail.com in HTML format, but my email has an attachment. The  attachment gets converted to a string, but I need it to be in the original file format.</p>
  
  <p>Code:</p>
  
  <pre><code>with FIdSmtp do
  begin
    // Configure IdSMTP
  end;
  
  FIdMessage.Clear;
  FIdMessage.MessageParts.Clear;
  FIdMessage.From.Address := 'EmailRemetente';
  FIdMessage.From.Name    := 'Apelido';
  FIdMessage.Subject      := 'Assunto';
  FIdMessage.Body.Text    := 'Mensagem';
  FIdMessage.Recipients.EMailAddresses := 'aEmailDestinatario'; //email destino  
  FIdMessage.BccList.EMailAddresses := StringReplace(Trim(BCCList.Text),#13#10,',',[rfReplaceAll]);  
  FIdMessage.ccList.EMailAddresses := StringReplace(Trim(CCList.Text),#13#10,',',[rfReplaceAll]);
  FIdMessage.ContentType := 'text/html';  // set html format
  
  _Anexo := TStringList.Create;
  try
    _Anexo.Text := aAnexos;
    for i := 0 to _Anexo.Count - 1 do
      TIdAttachmentFile.Create(FIdMessage.MessageParts,_Anexo.Strings[i]);
  finally
    _Anexo.Free
  end;    
  FIdSmtp.Send(FIdMessage);
  </code></pre>
  
  <p>Can someone help me?</p>