Solved

Can someone tell me how to send an html email?

Posted on 2004-04-08
3
508 Views
Last Modified: 2010-04-05
Can someone give me an example of how to send html messages with idSMTP ? (multi part message)
0
Comment
Question by:pucko
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
Ivanov_G earned 125 total points
ID: 10782965
Var
  IdSMTP1: TIdSMTP;
  IdMessage1: TIdMessage;
  i:integer;
  idText1: TidText;
  idText2: TidText;
  p: TidMessageParts;
  MyBody:TStrings;
Begin
  IdMessage1:=TIdMessage.Create(nil);
  IdSMTP1:=TIdSMTP.Create(nil);

  p := idMessage1.MessageParts;
  MyBody:=TStringlist.create;
  MyBody.Add('<b>Our message </b>');
  idText1 := TidText.Create(p, MyBody);
  idText1.ContentType := 'text/html';  
  idText2 := TidText.Create(p);
  idText2.ContentType := 'text/plain';
  idText2.Body.Text := 'Body Text';
 
  With IdMessage1 do
    Begin
      CharSet:='iso-8859-1';
      Encoding:=meMIME;
      ContentType:= 'multipart/mixed';  
      From.Text:='me@mydomain.com';
      Recipients.EMailAddresses:='to@yourdomain.com';
      Subject:='My subject';
      TIdAttachment.Create(IdMessage1.MessageParts,'tralala.pdf');
    End;
  IdSMTP1.Host:='mail.mydomain.com';  
  IdSMTP1.Connect(300);

  try
    IdSMTP1.send(IdMessage1);
  finally
    IdSMTP1.Disconnect;
  End;
  IdMessage1.Free;
  IdSMTP1.Free;
End;
0
 
LVL 1

Author Comment

by:pucko
ID: 10783674
In which unit do I find the TIdMessage;
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10784252

  unit IdMessage;

  on my machine it is in C:\Program Files\Borland\Delphi5\Indy\Source\ folder
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now