Fórum Imagem não aparece no email como deveria!!! #346557
24/09/2007
0
Tenho o seguinte código:
// Adiciona o TEXTO ao corpo da mensagem
newText := TIdText.Create(IdMessage.MessageParts,nil);
newText.ContentType := ´text/html´;
newText.Body.Add(´<HTML>´);
newText.Body.Add(´ <BODY>´);
newText.Body.Add(´ <P>´);
newText.Body.Add(´ <TABLE>´);
newText.Body.Add(´ <TR>´);
newText.Body.Add(´ <TD>´);
newText.Body.Add(´ <IMG>´);
newText.Body.Add(´ </TD>´);
newText.Body.Add(´ </TR>´);
for i := 0 to RichEdit1.Lines.Count-1 do
begin
newText.Body.Add(RichEdit1.Lines.Strings[i]+´<br>´);
end;
newText.Body.Add(´ </TABLE>´);
newText.Body.Add(´ </P>´);
newText.Body.Add(´ </BODY>´);
newText.Body.Add(´</HTML>´);
Envio um e-mail para o Hotmail e uma cópia para o Outlook. No outlook, a imagem aparece dentro da tabela, mas no Hotmail, aparece um quadrinho pequeno (que é pra ser a tabela) e a imagem, bem embaixo.
Alguém saberia me dizer o que que há de errado nisso?
Grato.
Lucas_spohr
Curtir tópico
+ 0Posts
24/09/2007
Massuda
<img src="http://example.com/sua.imagem.jpg" blablabla...
Gostei + 0
24/09/2007
Lucas_spohr
// Adiciona o TEXTO ao corpo da mensagem
newText := TIdText.Create(IdMessage.MessageParts);//,nil);
newText.ContentType := ´text/html´;
newText.Body.Add(´<HTML>´);
newText.Body.Add(´<HEAD>´);
newText.Body.Add(´<TITLE></TITLE>´);
newText.Body.Add(´</HEAD>´);
newText.Body.Add(´<BODY>´);
newText.Body.Add(´<table cellspacing=´0´ cellpadding=´0´ border=´1´>´);
newText.Body.Add(´<TR>´);
newText.Body.Add(´<TD>´);
if OpenPictureDialog1.FileName <> ´´ then
newText.Body.Add(´<IMG SRC=´´+ OpenPictureDialog1.FileName +´´><TR><TD>´);
for i := 0 to RichEdit1.Lines.Count-1 do
begin
newText.Body.Add(RichEdit1.Lines.Strings[i]+´<br>´);
end;
newText.Body.Add(´</TD>´);
newText.Body.Add(´</TR>´);
newText.Body.Add(´</TABLE>´);
newText.Body.Add(´</P>´);
newText.Body.Add(´</BODY>´);
newText.Body.Add(´</HTML>´);
fiz vários testes no código, adiconando algumas tags HTML, mas ñ adiantou...
Gostei + 0
24/09/2007
Massuda
Gostei + 0
24/09/2007
Lucas_spohr
Coloquei o cid no src img, mas continua não dando certo!
inclusive, adicionando o cid, no Outlook, a imagem não aparece...
Obrigado!
Gostei + 0
24/09/2007
Massuda
Gostei + 0
24/09/2007
Lucas_spohr
// Adiciona o TEXTO ao corpo da mensagem
newText := TIdText.Create(IdMessage.MessageParts,nil);//,nil);
newText.ContentType := ´text/html´;
newText.Body.Add(´<HTML>´);
newText.Body.Add(´<HEAD>´);
newText.Body.Add(´<TITLE></TITLE>´);
newText.Body.Add(´</HEAD>´);
newText.Body.Add(´<BODY>´);
newText.Body.Add(´<table cellspacing=´0´ cellpadding=´0´ border=´1´>´);
newText.Body.Add(´<TR>´);
newText.Body.Add(´<TD>´);
if OpenPictureDialog1.FileName <> ´´ then
newText.Body.Add(´<IMG SRC=´´+ OpenPictureDialog1.FileName +´´><TR><TD>´);
for i := 0 to RichEdit1.Lines.Count-1 do
begin
newText.Body.Add(RichEdit1.Lines.Strings[i]+´<br>´);
end;
newText.Body.Add(´</TD>´);
newText.Body.Add(´</TR>´);
newText.Body.Add(´</TABLE>´);
newText.Body.Add(´</P>´);
newText.Body.Add(´</BODY>´);
newText.Body.Add(´</HTML>´);
Gostei + 0
24/09/2007
Massuda
Parte do problema é que TOpenPictureDialog.FileName retorna um nome de arquivo que inclui o path completo do arquivo. A princípio, bastaria usar um ExtractFileName, mas para funcionar precisa criar o anexo de modo adequado.
O Outlook consegue mostrar a imagem porque provavelmente ela está na mesma máquina. Já o Hotmail (e qualquer um que receba seu email) não vai ver a imagem porque ela não está na máquina).
Gostei + 0
24/09/2007
Lucas_spohr
btn...
var
newText : TIdText;
newAttach : TIdAttachment;
i: integer;
imgID1, imgName1 : String;
begin
// Endereço e ID das Imagens
imgName1 := ExtractFileName(OpenPictureDialog1.FileName);
imgID1 := CreateUniqueID;
// Adiciona o TEXTO ao corpo da mensagem
newText := TIdText.Create(IdMessage.MessageParts,nil);//,nil);
newText.ContentType := ´text/html´;
newText.Body.Add(´<HTML>´);
newText.Body.Add(´<HEAD>´);
newText.Body.Add(´<TITLE></TITLE>´);
newText.Body.Add(´</HEAD>´);
newText.Body.Add(´<BODY>´);
newText.Body.Add(´<TABLE CELLSPACING=´0´ CELLPADDING=´0´ BORDER=´1´>´);
newText.Body.Add(´<TR>´);
newText.Body.Add(´<TD>´);
if OpenPictureDialog1.FileName <> ´´ then
newText.Body.Add(´<IMG SRC=´´+ ExtractFileName(OpenPictureDialog1.FileName) +´´><TR><TD>´);
for i := 0 to RichEdit1.Lines.Count-1 do
begin
newText.Body.Add(RichEdit1.Lines.Strings[i]+´<BR>´);
end;
newText.Body.Add(´</TD>´);
newText.Body.Add(´</TR>´);
newText.Body.Add(´</TABLE>´);
newText.Body.Add(´</P>´);
newText.Body.Add(´</BODY>´);
newText.Body.Add(´</HTML>´);
//Anexa a imagem ao corpo do E-mail
if OpenPictureDialog1.FileName <> ´´ then
begin
newAttach := TIdAttachment.Create(IdMessage.MessageParts,imgName1);
newAttach.ContentType := ´image/jpeg´;
newAttach.ContentDisposition := ´inline´;
newAttach.ExtraHeaders.Values[´Content-ID´] := ´<´+imgId1+´>´;
end;
eu mudei lá em cima, colocando ExtractFileName, no IMG SRC... mas ainda não funcionou!
Obrigado!
Gostei + 0
24/09/2007
Massuda
var Texto: TIdText; Html: TIdText; Imagem: TIdAttachment; ArquivoImagem: string; begin ArquivoImagem := OpenPictureDialog1.FileName; IdMessage.ContentType := ´multipart/mixed´; Texto := TIdText.Create(IdMessage.MessageParts); Texto.ContentType := ´text/plain´; Texto.Body.Text := ´This message contains HTML and images.´; Html := TIdText.Create(IdMessage.MessageParts); Html.ContentType := ´text/html´; Html.Body.Add(´<HTML>´); Html.Body.Add(´<BODY>´); Html.Body.Add(´<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="1">´); Html.Body.Add(´<TR>´); Html.Body.Add(´<TD>´); if ArquivoImagem <> ´´ then Html.Body.Add(´<IMG SRC="cid:´+ ExtractFileName(ArquivoImagem) +´"><TR><TD>´); for i := 0 to RichEdit1.Lines.Count-1 do begin Html.Body.Add(RichEdit1.Lines.Strings[i]+´<BR>´); end; Html.Body.Add(´</TD>´); Html.Body.Add(´</TR>´); Html.Body.Add(´</TABLE>´); Html.Body.Add(´</P>´); Html.Body.Add(´</BODY>´); Html.Body.Add(´</HTML>´); //Anexa a imagem ao corpo do E-mail if ArquivoImagem <> ´´ then begin Imagem := TIdAttachment.Create(IdMessage.MessageParts, ArquivoImagem); Imagem.ContentType := ´image/jpeg´; Imagem.Headers.Add(´Content-ID: <´+ExtractFileName(ArquivoImagem)+´>´); end;
Gostei + 0
24/09/2007
Massuda
Gostei + 0
24/09/2007
Lucas_spohr
mando um e-mail para o hotmail, o qualquer um, e a imagem ao invés de aparecer em cima, na primeira linha da tabela, aparece beem embaixo, logo abaixo da tabela!
obrigado...
up
Gostei + 0
24/09/2007
Lucas_spohr
qualquer coisa, posto aí o resultado...
Obrigado, Massuda!
Gostei + 0
24/09/2007
Lucas_spohr
Gostei + 0
24/09/2007
Massuda
Gostei + 0
24/09/2007
Lucas_spohr
Muitíssimo obrigado, cara!
putz... nem sei como agradecer... na boa... fiquei um tempão mudando códigos, e mais códigos HTML, e não tinha jeito de funcionar!
bah... menos mal! Espero agora, que não falte mais nada no projeto... hehe
Obrigado! Abraço... Sucesso!!!
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)