Stef Merlijn
asked on
How to send a '&' in a Email subject via ShellExecute
How can I send a '&' in a Email subject via ShellExecute.
Now I'm using following code to send an Email with default Email-program (Outlook Express).
procedure TFRelatiegegevens.StuurEma ilClick(Se nder: TObject);
Var Buffer : String;
Ontvanger,Onderwerp,EmailT ekst : String;
begin
Try
Ontvanger := IEmail.Text; {message recipients email address}
Onderwerp := 'E-mail van '+DM.TBedrijfsgegevens.Fie ldByName(' Naam').AsS tring; {message subject}
Emailtekst:= 'Hallo '+DM.TRelaties.FieldByName ('HeleNaam ').AsStrin g;
Buffer := 'mailto:'+Ontvanger+'?subj ect='+Onde rwerp+'&bo dy='+Email tekst;
ShellExecute(Application.H andle,'ope n',PChar(B uffer),nil ,nil,SW_No rmal);
Except
end;
end;
DM.TBedrijfsgegevens.Field ByName('Na am').AsStr ing contains a '&'.
The subject is displaying only the part before the '&'. Everything behind it is lost.
How can I solve this? -> preferrably not changing the '&' :-)
Thanks Stef.
Now I'm using following code to send an Email with default Email-program (Outlook Express).
procedure TFRelatiegegevens.StuurEma
Var Buffer : String;
Ontvanger,Onderwerp,EmailT
begin
Try
Ontvanger := IEmail.Text; {message recipients email address}
Onderwerp := 'E-mail van '+DM.TBedrijfsgegevens.Fie
Emailtekst:= 'Hallo '+DM.TRelaties.FieldByName
Buffer := 'mailto:'+Ontvanger+'?subj
ShellExecute(Application.H
Except
end;
end;
DM.TBedrijfsgegevens.Field
The subject is displaying only the part before the '&'. Everything behind it is lost.
How can I solve this? -> preferrably not changing the '&' :-)
Thanks Stef.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oops, forgot. You can also sent the whole text between double quotes. This will only work of course if your text doesn't contain them...
ASKER
And the function is born.
Bedankt allebei. Punten worden verdeeld. Beiden 125.
Function OmzettenAmpersand(Const E : string) : String;
begin
Result := E;
Result := StringReplace(result, '&', '%26', [rfReplaceAll]);
end;
Bedankt allebei. Punten worden verdeeld. Beiden 125.
Function OmzettenAmpersand(Const E : string) : String;
begin
Result := E;
Result := StringReplace(result, '&', '%26', [rfReplaceAll]);
end;
why not just:
Result := StringReplace(E, '&', '%26', [rfReplaceAll]);
:-)
Result := StringReplace(E, '&', '%26', [rfReplaceAll]);
:-)