Twebhtmlanchor problem

I am trying to send an email with the contents of some edit fields.

  1. If I add a mailto link in the properties the link works fine and pops up the mail application. However if I use he onclick event or mouse down and add
webhtmlanchor2.HREF :=  ' Subject&body=This is the body%0D%0Aline2';

The property in the inspector changes and if I click the link it works. But the click fails.

  1. Ideally I want to use a submit button and hide the Twebhtmlanchor so on abutton click I tried
  webhtmlanchor2.HREF :=  ' Subject&body=This is the body%0D%0Aline2';

but this failed.

What mysterious magic do I need to get this working please.

What about just calling like this:

procedure TForm1.WebButton1Click(Sender: TObject);
begin' Subject&body=This is the body%0D%0Aline2');

I wasn't aware of that thanks.

  1. How can I tie this into the required edit fields. IE only run the command when the submit is allowed.

  2. Also is it possible to use required on a combi dropdown and a memo field ?

Use a TWebHTMLForm and place your TWebEdit and TWebComboBox and TWebButton inside.
For TWebEdit just use the required property of the component.
For TWebComboBox do:

procedure TForm1.WebFormCreate(Sender: TObject);
  WebComboBox1.ElementHandle.setAttribute('required', '');

So button click will display the required messages, but I don't know IE much so you may need to set button type to submit but I am not sure of IE.

For the memo similar method should work

IE won't run the app anyway. Edge Chrome on window Chrome Safari n Mac are fine thanks.

Is there a way to stop the code running if the 'required' is not met.

make your button type submit via component property.
Don't override the button click event.
And finally use the OnSubmit event of your TWebHTMLForm component to trigger

procedure TForm1.WebHTMLForm1Submit(Sender: TObject);
begin' Subject&body=This is the body%0D%0Aline2');