Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Can someone tell me how to send an html email?

Posted on 2004-04-08
3
Medium Priority
?
538 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
Ivanov_G earned 500 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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

610 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