Hello every one.
I am having a great deal of trouble trying to embed images using cid to
reference the attached jpeg image.
This is some test code that sends the html formatted email with the
attached image, but does not display the image in line.
I have been using Thunderbird 1.5.0.9 to test this.
Regards,
Mike
procedure TForm1.Button1Click(Sender: TObject);
var
IdAttach: TIdAttachmentFile;
IdText1: TIdText;
IdText2: TIdText;
begin
IdSMTP.Host := 'smtp.maxnet.co.nz';
IdSMTP.Port := 25;
IdSMTP.Username := '';
IdSMTP.Password := '';
IdMessage.From.Address := '[EMAIL PROTECTED]';
IdMessage.Recipients.EMailAddresses := '[EMAIL PROTECTED]';
IdMessage.Subject := 'test';
IdMessage.Sender.Address := '[EMAIL PROTECTED]';
IdMessage.ContentType := 'multipart/mixed';
IdMessage.Body.Add('<html>');
IdMessage.Body.Add('<head></head>');
IdMessage.Body.Add('<body>');
IdMessage.Body.Add('<br /><br /><span
style="color:red;font-weight:bold;">Here is the image:</span><br /><br
/><br />');
IdMessage.Body.Add('<img src="cid:sm101yellow.jpg" />');
IdMessage.Body.Add('</body>');
IdMessage.Body.Add('</html>');
IdText1 := TIdText.Create(IdMessage.MessageParts, IdMessage.Body);
IdText1.ContentType := 'text/html';
IdText2 := TIdText.Create(IdMessage.MessageParts);
IdText2.ContentType := 'text/plain';
IdText2.Body.Text := '';
IdAttach := TIdAttachmentFile.Create(IdMessage.MessageParts,
'd:\sm101yellow.jpg');
IdAttach.ContentType := 'image/jpeg';
IdAttach.ContentDisposition := 'inline';
IdAttach.ContentID := 'sm101yellow.jpg';
IdAttach.DisplayName := 'sm101yellow.jpg';
try
try
IdSMTP.Connect;
IdSMTP.Send(IdMessage);
except
on E:Exception do
ShowMessage('Failed to send Email!'+#13#10+e.message);
end;
finally
if IdSMTP.Connected then
IdSMTP.Disconnect;
end;
Showmessage('Email Sent');
end;
_______________________________________________
Delphi mailing list
Delphi@ns3.123.co.nz
http://ns3.123.co.nz/mailman/listinfo/delphi