Re: Problem with smtp on Indy10

Giganews Newsgroups
Subject: Re: Problem with smtp on Indy10
Posted by:  Remy Lebeau \(Indy Team\) (no.spam@no.spam.com)
Date: Sun, 3 May 2009

"Hershcu S" <sori…@zahav.net.il> wrote in message
news:397398E66A7FE340sori…@zahav.net.il...

>  FMessage.Body := Body;
>  if FileExists(AttacheFile) then
>    TIdAttachmentFile.Create(FMessage.MessageParts,  AttacheFile);

When using the MessageParts property, you need to put the body text into a
TIdText object.  Do not use the TIdMessage.Body property.

>  FMessage.CharSet := 'IBM862';    // this line for hebrew letters

DO NOT assign the TIdMessage.CharSet property when using the MessageParts
property.  You must set the CharSet on each individual MessageParts item
instead.

Try this instead:

procedure TSendMail.SetMessageVal(const FromName, FromAddr, To, AttacheFile:
String; Body: TStrings);
begin
  FMessage.From.Address := FromAddr;
  FMessage.From.Name := FromName;
  FMessage.Recipients.EMailAddresses := To;
  if FileExists(AttacheFile) then
  begin
    with TIdText.Create(FMessage.MessageParts, Body) do
    begin
      CharSet := 'IBM862';
      ContentType := 'text/plain';
    end;
    TIdAttachmentFile.Create(FMessage.MessageParts, AttacheFile);
    FMessage.ContentType := 'multipart/mixed';
  end else
  begin
    FMessage.Body := Body;
    FMessage.CharSet := 'IBM862';
    FMessage.ContentType := 'text/plain';
  end;
end;

You should consider using the TIdMessageBuilder... classes, which handle
these details for you.

--
Remy Lebeau (Indy Team)

Replies

In response to

Problem with smtp on Indy10 posted by Hershcu S on Wed, 29 Apr 2009