I got an erros on the attachmente line....
Any ideas?
dELPHI xe2
Code:
procedure TForm1.Button1Click(Sender: TObject);
var
Email: TIdMessage;
Texto: TIdText;
Html: TIdText;
Anexo: TIdAttachment;
begin
Email := TIdMessage.Create(nil);
try
// ...ajusta remetente, destinatário, etc...
// define o tipo do conteúdo da mensagem
Email.ContentType := 'multipart/mixed';
// cria a parte texto - pode estar em branco
Texto := TIdText.Create(Email.MessageParts);
Texto.Body.Text :=
'This message contains HTML and images.';
Texto.ContentType := 'text/plain';
// cria a parte HTML
Html := TIdText.Create(Email.MessageParts);
Html.Body.Text := '<html><body>'
+ 'Mensagem de <b>Teste</b><br />'
+ '<img src="cid:imagem.jpg" />'
+ '</body></html>';
Html.ContentType := 'text/html';
// inclui no email a imagem usada na parte HTML
Anexo := TIdAttachment.Create(Email.MessageParts, 'c:\pasta\imagem.jpg'); <<<<<<<<<<<<<<<<<<< THIS LINE HAS ERROR
//email.MessageParts.Add('c:\pasta\imagem.jpg'));
Anexo.ContentType := 'image/jpg';
Anexo.Headers.Add('Content-ID: <imagem.jpg>');
// ... envia o email...
finally
Email.Free;
end;
end;