i+need+to+create+a+substring+mail+link+inside+the+web+browser

I have created a mail program that use web browser as the body.

I must add a unsubscribe for the email body.

The code3 worked fine when I was using Delphi XE 8 . Now I am using Delphi XE 10.2.

My Code..
I have called TwebBrowser "htmlEditor"

Procedure TFrame15.Button1Click(Sender: TObject);
Var
  htmlDoc: IHTMLDocument2;
  HtmlSelObj: IHTMLSelectionObject;
  HtmlTxtRng: IHTMLTxtRange;
  S: WideString;
begin
  htmlDoc := htmlEditor.Document as IHTMLDocument2;
  htmlDoc.execCommand('InsertImage', false, '');
  HtmlSelObj := htmlDoc.selection;
  c:=('<a href=''mailto:'' + b + '?subject Unsubscribe>Unsubscribe</a>'''');
   if HtmlSelObj.type_ = 'Control' then
    HtmlSelObj.Clear;
    HtmlTxtRng := HtmlSelObj.createRange as IHTMLTxtRange;
    HtmlTxtRng.pasteHTML(S);
   htmlEditor.SetFocus();  
end;

Open in new window

Franco AlbertsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Franco AlbertsAuthor Commented:
B is a variable using my emailaddress and variable c must be S...
0
Sinisa VukSoftware architectCommented:
if you prepare c variable - why you put s in call pasteHTML(S) ?
0
Franco AlbertsAuthor Commented:
Just a typing mistake. I explained already..
0
Sinisa VukSoftware architectCommented:
If you put:
HtmlSelObj := htmlDoc.selection;
if Assigned(HtmlSelObj) then
begin
   S:=('<a href=''mailto:'' + b + '?subject Unsubscribe>Unsubscribe</a>'''');
   if HtmlSelObj.type_ = 'Control' then
    HtmlSelObj.Clear;

    ShowMessage(S);

    HtmlTxtRng := HtmlSelObj.createRange as IHTMLTxtRange;
    HtmlTxtRng.pasteHTML(S);
   htmlEditor.SetFocus();  
end;

Open in new window


... do you see Message dialog showing S value?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.