Enviar email em HTML com imagem em anexo

Delphi

31/01/2007

Olá pessoal, boa tarde!

Li vários tópicos aqui no forum que falavam sobre o envio de email no formato HTML mostrando a imagem ´inline´ e infelizmente ainda não consegui.

Estou tentando assim:

begin
  //Configurando o servidor SMTP
  
  ConfigSMTP;

  IdSMTP1.Connect;
  try
    if IdSMTP1.Connected then
    begin
      with IdMessage1 do
      begin
        Subject := ´Teste de envio de mensagem com html mostrando uma imagem "inline"´;
        From.Name := ´Carlos Alberto ´+FormatDateTime(´ hh:mm:ss:zzz´, now);
        From.Address := ´carlos@carlos.eti.br´;
        Recipients.Add.Address := ´carlos_am@hotmail.com´;
        Recipients.Add.Address := ´carlosib_2005@click21.com.br´;
        ContentType := ´multipart/alternative´;
        ContentDisposition := ´inline´;
        Encoding := meMIME;
      end;


      //Part 0 TXT.
      with TIdText.Create(IdMessage1.MessageParts) do
      begin
         Body.Clear;
         Body.Add(´Mensagem texto´);
         ContentType := ´text/plain´;
         ContentTransfer := ´7bit´;
      end;


      with TIdText.Create(IdMessage1.MessageParts) do
      begin
        Body.Clear;
        ContentType := ´multipart/related´;
        ContentTransfer := ´7bit´;
      end;

      //Part 1 HTML.
      with TIdText.Create(IdMessage1.MessageParts) do
      begin
         Body.Clear;
         Body.LoadFromFile(´c:\mala.html´);  //File HTML
         ContentType := ´text/html´;
         ContentTransfer := ´7bit´;
      end;

      with TIdAttachment.Create(IdMessage1.MessageParts, ´c:\CAP1.jpg´) do
      begin
        ContentType := ´image/jpg´;
        ContentDisposition := ´inline´;
        ContentTransfer := ´base64´;
        Headers.Clear;
        Headers.Add(´Content-ID: <CAP1.jpg>´);

      end;
      IdSMTP1.Send(IdMessage1);

    end;
  finally
  end;


O conteúdo do arquivo ´Mala.html´ é:
<html>
<head>
</head>
<body>
<p>Veja a imagem abaixo:</p>
<p><img border="0" src="CAP1.jpg" width="1024" height="768"></p>
</body>
</html>


No webmail do hotmail do click21 e no outlook express vejo a imagem dessa forma:

HOTMAIL:


CLICK21:

OUTLOOK EXPRESS

Alguém consegue ver o que estou fazendo de errado?

Uso Delphi 7 - Indy 9.0.19


Carlosib

Carlosib

Curtidas 0

Respostas

Massuda

Massuda

31/01/2007

Veja :arrow: [url=http://forum.clubedelphi.net/viewtopic.php?t=81650]este tópico[/url]. Um detalhe importante é como seu HTML está fazendo referencia à imagem e tem outro relacionado a ter que ter uma parte texto na sua mensagem.


GOSTEI 0
Carlosib

Carlosib

31/01/2007

Massuda,

gerei esse código HTML com o front page:


<html>

<title>Teste de envio de email com imagem anexo e outros arquivos</title>

<body>

<h1><font color="#008000" face="ATICHAR">Teste de envio de mensagem....</font></h1>

<p><a href="http://www.agenda.eti.br"><img border="0" src="cid:0123456789" width="500" height="1000"></a></p>

</body>

</html>



O código que adicionar a imagem ´inline´ no email é:

      TheAttachment := TIdAttachmentFile.Create(TheMessage.MessageParts, ExtractFilePath(ParamStr(0))+´imagem.jpg´);
      TheAttachment.ContentTransfer := ´base64´;
      //Next line works on most extensions, a real app would do this properly...
      TheAttachment.ContentType := ´image/jpg´//            TheAttachment.ContentID := ´<0123456789>´;
      TheAttachment.ParentPart := 0;


No outlook, webmail do click21 a imagem é mostrada. No webmail do HOTMAIL a imagem não é mostrada.

Você saberia me dizer porque?

WEBMAIL CLICK21

HOTMAIL

OUTLOOK EXPRESS

Como devo fazer para que o webmail do HOTMAIL mostre a imagem?


GOSTEI 0
Massuda

Massuda

31/01/2007

Parece que você teve algum progresso... infelizmente, não posso te ajudar com relação ao Hotmail. Já experimentou remover as linhas que mudam os valores TheAttachment.ContentTransfer e TheAttachment.ParentPart?


GOSTEI 0
POSTAR