Mega Code Archive

 
Categories / Delphi / LAN Web TCP
 

Html mail gönderme

var idAttach: TidAttachment; idText1: TidText; idText2: TidText; p: TidMessageParts; slBody: TStringList; begin idMessage1.Recipients.Add; idMessage1.Recipients[0].Address := 'girlswants_me@yahoo.com'; p := idMessage1.MessageParts; slBody := TstringList.Create; try // you can actually load the body from a RichEdit with // slBody.Text := RichEdit1.LinesText; slBody.Add('<html>'); slBody.Add('<head>'); slBody.Add('</head>'); slBody.Add('<body>'); slBody.Add('<br /><br /><b><font color="red">Here is the image:</font></b><br /><br /><br />'); slBody.Add('<img src="cid:sm101yellow.jpg" />'); slBody.Add('</body>'); slBody.Add('</html>'); idText1 := TidText.Create(p, slBody); idText1.ContentType := 'text/html'; idText2 := TidText.Create(p); idText2.ContentType := 'text/plain'; idText2.Body.Text := ''; // This shows how to add an attachment idAttach := TidAttachment.Create(p, 'c:\sm101yellow.jpg'); idAttach.ContentType := 'image/jpeg'; idAttach.ContentDisposition := 'inline'; idAttach.ExtraHeaders.Values['content-id'] := 'sm101yellow.jpg'; idMessage1.Body.Assign(slBody); idAttach.DisplayName := 'sm101yellow.jpg'; idMessage1.ContentType := 'multipart/mixed'; idSMTP1.Connect; idSMTP1.Send(idMessage1); finally idSMTP1.Disconnect; slBody.Free; Showmessage('done'); end; end;