SMTP & Rich Text
Hi all
I am trying to use the SMTP component in Delphi 5 to send an email in Rich
Text format. I have set the property to "Enriched".
I load in a Rich Text document to a RTMemo and it looks fine. I then load
it into the Body of the PostMessage property and send it but all the
formatting disappears when the email comes through.
I have tried saving to a stream and loading back but then all I get is a raw
text message with all the RTF codes.
Any ideas?
Regards
John
........................................
procedure TfrmLetterProcessingRun.EmailDocument;
var
i: integer;
p: integer;
vLine: string;
TempStream: TMemoryStream;
begin
EmailBody.Clear;
EmailBody.Lines.LoadFromFile(frmLetterProcessing.tblLetterDocumentLocation.T
ext);
for i:=0 to EmailBody.Lines.Count-1 do
begin
vLine:=EmailBody.Lines[i];
if Pos('&&',vLine)>0 then
begin
p:=Pos('&&Salutation&&',vLine);
if p>0 then
begin
Delete(vLine,p,14);
Insert(frmLetterProcessing.tblLetterDetailContactSalutation.Value,vLine,p);
end;
end;
EmailBody.Lines[i]:=vLine;
end;
SMTP.PostMessage.LocalProgram := 'Marketing v2.0';
SMTP.PostMessage.FromName := 'GBA Computer Solutions';
SMTP.PostMessage.FromAddress := tblDocumentEmailFrom.Value;
SMTP.PostMessage.Subject := tblDocumentEmailDesc.Value;
SMTP.PostMessage.ToAddress.Clear;
SMTP.PostMessage.ToAddress.Add('j...@gbasolutions.co.uk');
SMTP.PostMessage.ToBlindCarbonCopy.Text:='';
SMTP.PostMessage.ToCarbonCopy.Text:='';
SMTP.PostMessage.Attachments.Text:='';
SMTP.PostMessage.Body.Clear;
try
TempStream:=TMemoryStream.Create;
EmailBody.Lines.SaveToStream(TempStream);
TempStream.Position:=0;
SMTP.PostMessage.Body.LoadFromStream(TempStream);
finally
TempStream.Free;
end;
try
SMTP.SendMail;
except
ShowMessage( 'There was a problem sending mail to the SMTP
server.'#13+
'Please contact network administator.'#13'IP Address
= '+SMTP.Host);
Exit;
end;
end;