[DUG] Indy emails
Jeremy Coulter
jscoulter at gmail.com
Fri Oct 24 12:51:49 NZDT 2014
actually what it turned out to be was me thinking that Indy was smart
enough to know if I am passing images in the "Htmlfiles.add()" the
TMessageBuilderHTML that it would have replaced the "src" for the image to
src="cid:x" (x=image index) but I had to do it myself!
Anyway, it works now.
Jeremy
On Fri, Oct 24, 2014 at 11:44 AM, Robert Martin <rob at chreos.co.nz> wrote:
> Hi Jeremy
>
> You are right to use TIdMessageBuilderHTML, it is almost impossible to get
> it working correctly otherwise! I do have it working fine. Below is a
> snippet from my send class....
>
>
> //RM 2012/12/06 Use TIdMessageBuilderHtml to build
> email, too hard to do it manually, didn't 100% work
> IdMessageBuilderHtml := TIdMessageBuilderHtml.Create;
> try
> IdMessageBuilderHtml.HtmlCharSet :=
> 'UTF-8'; //RM 2013/11/04 added to deal with UTF8 text
> IdMessageBuilderHtml.Html.Text := fBodyText;
>
> //Add inline attachments
> if (fInlineAttachments.Count > 0) then begin
> for Counter := 0 to fInlineAttachments.Count -
> 1 do begin
> InlineAttachment :=
> TInlineAttachment(fInlineAttachments[Counter]);
>
>
> IdMessageBuilderHtml.HtmlFiles.Add(InlineAttachment.FileName);
>
> IdMessageBuilderHtml.HtmlFiles[Counter].ContentType := 'image/jpg';
>
> IdMessageBuilderHtml.HtmlFiles[Counter].ContentID := '<' +
> InlineAttachment.ContentID + '>';
> end;
> end;
>
>
> //Add email attachments
> WorkList := TStringList.Create;
> try
> //build list of files
> LoadFileList(WorkList, fFileNames);
>
> while (WorkList.Count > 0) do begin
>
> IdMessageBuilderHtml.Attachments.Add(WorkList[0]);
>
> WorkList.Delete(0);
> end;
>
> finally
> WorkList.Free;
> end;
>
> IdMessageBuilderHtml.PlainText.Text := ' ';
> IdMessageBuilderHtml.FillMessage(EmailMessage);
> finally
> IdMessageBuilderHtml.Free;
> end;
>
>
>
>
> TInlineAttachment is a class I have, the definition is below...
>
> //Rm 2012/11/02 class added to detail each inline image
> TInlineAttachment = class
> private
> fContentID : String; //Link to tag in HTML body (i.e.
> html might be '<img src="cid:us.jpg" />' so fContentID is 'us.jpg'
> fContentType : String; //What type of content i.e.
> 'image/jpeg' for a jpg image
> fFileName : String; //Qualified link to image file
> public
> property ContentID : String read fContentID write fContentID;
> property FileName : String read fFileName write fFileName;
> property ContentType : String read fContentType write fContentType;
>
> Constructor Create(aContentID, aFileName, aContentType : String);
> end;
>
>
>
> Content ID is just a unique name. In the code this is from they are
> things like 'header.jpg'.
>
> Hope that gets you going. I can show you more code if you need.Â
>
> Cheers
> Rob
>
>
>
>
>
> On 23/10/2014 6:51 p.m., Jeremy Coulter wrote:
>
> Hi All.
> I am using Indy to send emails. I have swapped from another control to
> Indy.
> The emails are HTML email, HOWEVER.....when I am sending emails with
> embedded images, but they are not displaying in the actual email, with the
> location where the image should appear displaying the red "x" in a box. The
> image IS in the email and it appears as an attachment when I open the email.
>
> I did a bit of a search around and found that there is now a new class
> called TIdMessageBuilderHTML. I have copy and pasted the example from the
> INDY website, and it made no difference. It LOOKED promising :-(
>
> I have tried creating the email using the correct context type and using
> the messagepart property setting the contentdisposition to inline etc, but
> I get the same result!
>
> Has anyone ever got this too work as it should?
>
> Thanks, Jeremy
>
>
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi at listserver.123.net.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-request at listserver.123.net.nz with Subject: unsubscribe
>
>
>
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 2015.0.5315 / Virus Database: 4181/8435 - Release Date: 10/22/14
>
>
>
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi at listserver.123.net.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-request at listserver.123.net.nz with
> Subject: unsubscribe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20141024/36311f15/attachment.html
More information about the Delphi
mailing list