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?
 
Franco AlbertsAuthor Commented:
B is a variable using my emailaddress and variable c must be S...
0
 
Sinisa VukCommented:
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 VukCommented:
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
All Courses

From novice to tech pro — start learning today.