上面的兄弟,我按照你的方式做了,可以发送附件,但是图片在邮件服务器端没有看到,也不是红色的 X号,显示的是HTML的源码,请问是怎么回事呢:
IdSMTP1.Host := 'XXX';
IdSMTP1.Username := 'XXX';
IdSMTP1.Password := 'XXX';
IdMessage1.Subject := 'XXX';
IdMessage1.Body.Add('<html>');
IdMessage1.Body.Add(' <head>');
IdMessage1.Body.Add(' <title>Hello</title>');
IdMessage1.Body.Add(' </head>');
IdMessage1.Body.Add(' <body title="' + 'Test Html"');
IdMessage1.Body.Add(' Hello, friends.<br/>');
IdMessage1.Body.Add(' <br/>');
IdMessage1.Body.Add(' <img src="cid
rettyPic" name="MM.jpg">');
IdMessage1.Body.Add(' </body>');
IdMessage1.Body.Add('</html>');
IdMessage1.From.Address := 'XXX';
IdMessage1.Recipients.EMailAddresses := 'XXX';
{添加HTML图片}
attachment := TIdAttachmentFile.Create(IdMessage1.MessageParts,
'C://Documents and Settings//zyz//桌面//MM.jpg');
attachment.ExtraHeaders.Values['Content-ID'] := '<PrettyPic>';
attachment.ContentType := 'image/jpeg';
IdMessage1.MessageParts.Items[0].ContentType := 'text/html';
IdMessage1.ContentType := 'multipart/related';
try
IdSMTP1.Connect;
IdSMTP1.Send(IdMessage1);
ShowMessage('Send Complete!');
finally
IdSMTP1.Disconnect;
end;