Solved

Can someone tell me how to send an html email?

Posted on 2004-04-08
3
514 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…

730 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