PAGUE 6 MESES
LEVE 12 MESES
GARANTIR DESCONTO

Fórum Indy com Anexo #233455

21/05/2004

0

Estou tendo problemas para enviar e-mail com anexo em formato html.
O Código:

procedure TF_EA.BitBtn3Click(Sender: TObject);
Var
  l_Manda:String;
  i:Integer;
begin
  IF Edit2.Text=´´     Then Begin
    ShowMessage(´Assunto em branco´);
    Exit;
  End;
  IF ComboBox1.Text=´´ Then Begin
    ShowMessage(´Tipo de mensagem não selecionada´);
    Exit
  End;

  with smtp do
  begin
    Host:=TRIM(DM.ADOTable_ConfHOST.Value);
    IF not DM.ADOTable_ConfUSERNAME.IsNull Then AuthenticationType:=atLogin;
    Username:=TRIM(DM.ADOTable_ConfUSERNAME.Value);
    Password:=TRIM(DM.ADOTable_ConfPASSAWORD.Value);
    SMTP.Connect();
  end;

  DM.ADOTable_Cont.First;
  IF ComboBox2.Text = ´Todos´ Then Begin
    While not DM.ADOTable_Cont.Eof Do Begin
      l_Manda:=´N´;
      IF DM.ADOTable_ContRecebe.Text=´Verdadeiro´ Then Begin
        IF  DM.ADOTable_ContGrupo.Value = ´Todos´ Then
        Begin
          l_Manda:=´S´;
          IdMessage.BccList.Add.Address:=TRIM(DM.ADOTable_ContEMail.Value);
        End;
      End;
      DM.ADOTable_Cont.Next;
    End;
  End
  Else
  Begin
    IdMessage.BccList.Clear;
    IF DM.ADOTable_Cont.locate(´Nome´,ComboBox2.Text,[]) Then Begin
      IdMessage.BccList.Add.Address:=DM.ADOTable_ContEMail.Value;
    End
    Else
    Begin
      IdMessage.BccList.Add.Address:=trim(ComboBox2.Text);
    End;
    l_Manda:=´S´;
  End;
  IF l_Manda=´S´ Then Begin
    Memo1.WordWrap:=False;

    with IdMessage do
    begin
      From.Address:=TRIM(DM.ADOTable_ConfADDRESS.Value);
      From.Name:=TRIM(DM.ADOTable_ConfNAME.Value);
      Subject := TRIM(ComboBox1.Text) + ´ - ´ + TRIM(EDIT2.Text);

      MessageParts.Clear;
      FOR i:=0 TO ListBox1.Count-1 DO
        TIdAttachment.Create(MessageParts, ListBox1.Items.Strings[i]);

      ContentType:=´text/html´;
      Body.Clear;
      Body.Add(´<html><head></head><body><i><font face=Times New Roman size=4 color=000080>´);
      IF Memo1.Lines.Count <> 0 Then
        FOR i:=0 TO Memo1.Lines.Count do
          Body.Add(Memo1.Lines.Strings[i] + ´<br>´);

      IF ComboBox3.Text <> ´´ Then
      Begin
        Memo1.Clear;
        Memo1.Text:=DM.ADOTable_Mensmen.value;

        IF DM.ADOTable_Mensgru.Value=´Poesias´ Then
          Body.Add(´<p align=center>´);

        FOR i:=0 TO Memo1.Lines.Count do
          Body.Add(Memo1.Lines.Strings[i] + ´<br>´);

        IF DM.ADOTable_Mensgru.Value=´Poesias´ Then
           Body.Add(´</p>´);
      End;
      Body.Add(´</font></i><p><font face=Brush Script color=#000080 size=6>Atenciosamente</font><font face=French Script MT color=000080 size=6><br></font><img border=0 src=http://www.unimed-andradina.com.br/images/CMR.jpg width=273 height=41><font color=000080 size=2>´);
      Body.Add(´<br><i>Caso não queira mais receber estes e-mails favor <a title=Clique aqui para se remover href=mailto:lucianogarbelini@msn.com?subject=Remover><font color=000080>clique aqui</font></a></font></b></i></p></body></html>´);
    end;
    SMTP.Send(IdMessage);
  End;
  Memo1.WordWrap:=True;
  IdMessage.BccList.Clear;
  SMTP.Disconnect;
  Edit2.Text:=´´;
  ComboBox1.Text:=´´;
  ComboBox2.Text:=´Todos´;
  ComboBox3.Text:=´´;
  Memo1.Clear;
  IF CheckBox1.Checked=True Then
  Begin
    FOR i:=0 TO ListBox1.Count-1 DO
      DeleteFile(ListBox1.Items.Strings[i]);
  End;
  ListBox1.Clear;
  ShowMessage(´E-mail´s enviado com sucesso!´);
end;


O problema é que quando eu anexo algum arquivo o corpo da mensagem não sai correto, ele sai os comando de html. Como faço para resolver isso.

Obrigado


Lucianogar

Lucianogar

Responder

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar