Page 1 of 1

create and send HyperLink by email

Posted: Thu Apr 19, 2012 12:26 pm
by RoniTevel
Hi There
I use a TRichViewEdit compnent to edit email body.
i need to add HyperLink to the email body and
make shure it will be link when sending it by email.

Rve.SaveHTML(EmailTempFile, '', 'img', [rvsoOverrideImages,rvsoOverrideImages]);
HtmlBody:=FileToStr(EmailTempFile); //***-
if cbxHebrew.Checked then
HtmlBody:=StrTran(HtmlBody,'dir=LTR','dir=RTL');

any idea how to do it?
Roni

Posted: Thu Apr 19, 2012 12:37 pm
by Sergey Tkachenko
Store a hyperlink target in the item Tag.
If you use RichViewActions, TrvActionInsertHyperlink does all work for you.
If not, see the demo in Demos\*\Assorted\Hypertext\CreateHyperlink

To save hyperlinks in HTML, use OnWriteHyperlink event:

Code: Select all

procedure TfrmMain.rveWriteHyperlink(Sender: TCustomRichView; id: Integer;
  RVData: TCustomRVData; ItemNo: Integer; SaveFormat: TRVSaveFormat;
  var Target, Extras: string);
begin
  Target := RVData.GetItemTag(ItemNo);
end;

Posted: Thu Apr 19, 2012 1:08 pm
by RoniTevel
Thnks Sergey.
can you upload code sample how to
store a hyperlink in item tag?
Roni

Posted: Thu Apr 19, 2012 7:00 pm
by Sergey Tkachenko
If you do not use RichViewActions, see the demo in Demos\*\Assorted\Hypertext\CreateHyperlink

What exactly do you want to know?

In this demo, you can see how hyperlinks are created:
- for inserting a new hyperlink, InsertStringTag is used
- for making a hyperlink from the selected text, ApplyStyleConversion and SetItemTagEd are used.

No additional code is required to store tags in RVF (in older version of TRichView, it was required to include rvoTagsArePChars in Options, but now it is not needed).
To save hyperlinks in HTML or RTF, OnWriteHyperlink is used, as I said above.
To read hyperlinks from RTF, OnReadHyperlink is used.