Solved

Can someone tell me how to send an html email?

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

758 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

22 Experts available now in Live!

Get 1:1 Help Now