[Lazarus] ShellExecute and german umlauts

John Landmesser jmlandmesser at gmx.de
Thu May 21 15:26:18 CEST 2015



Am 21.05.2015 um 11:37 schrieb Henry Vermaak:
> On Thu, May 21, 2015 at 10:06:28AM +0200, John Landmesser wrote:
>> i want to send a mail on windows using shellexecute with german
>> Umlauts ( ö,å,ü .. ) in the body of the mail.
>>
>> This Code doesn't work:
>>
>> var s: string;
>>
>> s := 'öööööö'
>>
>>
>> shellexecute(Application.Mainform.handle, 'open',PChar('mailto:' +
>> 'example at gmail.com' + '?subject=' + 'ARJ-ChapterArchiv: ' +
>> '&body=' + UTF8ToAnsi(s)),nil, nil, sw_normal);
>>
>>   Good tipps are welcome!    I don't want to use Indy or synapse!
> I use something like this:
>
> if Win32MajorVersion < 5 then
> 	Ret := ShellExecute(0, 'open', PChar(UTF8ToSys(AProg)), nil, nil, SW_SHOWNORMAL)
> else
> 	Ret := ShellExecuteW(0, 'open', PWideChar(UTF8Decode(AProg)), nil, nil, SW_SHOWNORMAL);
>
> Result := Ret > 32;
>
> Henry
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


thanks Henry!

found a solution that is ok with umlauts in body:

        var list : TStringList; // body
                 s : string; // for body without LFN and spaces

        (* LFN replace: *)
       for x := 0 to list.Count -1 do
       s := s + '%0D%0A' + List[x];

       (* replace Spaces : *)
       s := StringReplace(s,' ','%20',[rfReplaceAll, rfIgnoreCase]);


       cmdLine := 'mailto:example at gmail.com?subject=ARJ-ChapterArchiv: 
'  + ArchName + '&body=' + s;
       if not Openurl(cmdLine) then

that works, but i don't know why, Perhaps your

PChar(UTF8ToSys(AProg))

and

PWideChar(UTF8Decode(AProg))


is the trick?






More information about the Lazarus mailing list