Html mail displays differently than the body text does...
I am using Indy 10 (latest trunk version) in Lazarus to create a
command line utility to interface with our new Subversion repository
server. It sends commit emails to select users with some information
including a list of changed files and with a URL line to allow the
recipient to access the file from the VisualSVN web interface.
This has worked fine until today when I tried a test case where the
file is named with the Swedish characters ÅÄÖåäö as part of the file
name. When I commit this file all seems to go fine and the file
appears as expected in the VSVN web interface with the correct name.
But in the received email the file name and URL is corrupted and
cannot be read or used. THe Swedish characters have been replaced by
question marks in black diamonds.
As part of the email sending the program logs stuff and it also
creates a file on disk with the mail body content (basically
If I open this file in Chrome it displays properly with the correct
URL and name.
But in the received email I don't see this, neither in Outlook on the
PC nor in the Samsung Mail app on my phone.
How should I format the html part of the email when loading it into
the TIdSMTP component for sending?
Currently I use a TStringList container as follows:
function CreateFileURL(Server, Repo, FilePath: string): string;
sURL := Server + '/!/#' + Repo + '/view/head/' + FilePath;
Result := '<a href="' + sURL + '">' + ExtractFileName(FilePath) +
Re: Html mail displays differently than the body text does...
On Thu, 18 Jan 2018 18:46:28 +0100, Bo Berglund
<[hidden email]> wrote:
>I have already set the message to use UTF-8 via the messagebuilder:
>IB := TIdMessageBuilderHtml.Create;
>IB.HtmlCharSet := 'UTF-8';
>IB.Html.Text := slBody.Text;
>IB.PlainText.Text := slTxtBody.Text;
I ended up completely removing the line
IB.HtmlCharSet := 'UTF-8';
Then I added a "translator" function which replaces Swedish characters
in a string with the HTML escape sequences. I call this function to
wash text before inserting into the HTML mail body.
This solved the mailing problem for the case where new files and
folders are using these characters. But the existing names erroneously
converted (from cvs to svn) I have to manually rename via Subversion
to get right for the future. Hopefully there are only a handful of
such files/folders (I have so far found about a dozen).