Making HTML email client with CleverComponents

News about TRichView, ScaleRichView, ReportWorkshop, RVMedia
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Making HTML email client with CleverComponents

Post by Sergey Tkachenko »

The Clever Internet Suite ( http://www.clevercomponents.com ) represents 100% Delphi VCL components for Borland Delphi / C++Builder, with no external dependencies.
These components allow you to send and receive mail, including HTML and MIME attachments, from within an application, download and upload Internet resources over most popular protocols.


This file contains several useful functions allowing using TRichViewEdit as an editor for HTML emails:
(the link removed is, see the comments at the and of this message)
The units use CleverComponents for sending, receiving and parsing HTML emails.
The units include functions for:
  • sending HTML email composed in TRichViewEdit control;
  • displaying a dialog window for creating a new HTML email (allowing to compose email with rich text, images, attachments); email is sent after closing this dialog window;
  • displaying the same dialog for viewing email (in read-only mode)
  • displaying this dialog for replying to or forwarding email.
The dialog uses RichViewActions ( http://www.trichview.com/resources/actions/ )
The functions that need reading existing HTML emails (viewing, forwarding, replying) uses TrvHtmlViewImporter ( http://www.trichview.com/resources/#components )

Three demo projects are available:
  • Sending email from TRichViewEdit control
  • Sending email using a dialog window
  • Basic but full functional email client
Compiled demo of this email client:
http://www.trichview.com/resources/clev ... client.zip

Screenshot:
Image

Updates:
2012-Dec-25: fix for attached images (see the discussion below); compatibility with TRichView 14.
2013-Jul-7: RVAContolPanel is placed on the mail editing form and assigned to all actions explicitly
2016-Aug-9: updated for compatibility with newer version of CleverComponents
2016-Nov-8: link to source code is removed, because it is included in the installer of TRichView (ThirdParty\CleverComponents\Demos\ folder)
Last edited by Sergey Tkachenko on Tue Nov 08, 2016 11:52 am, edited 4 times in total.
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Updated:
- corrections in processing attached images
- using the latest (googlecode's) version of THTMLViewer for loading HTML emails (a code working with older version is not removed but commented)
bilgin
Posts: 2
Joined: Mon Nov 26, 2012 9:00 pm

Compiled demo is not working correctly !

Post by bilgin »

Hi

i've downloaded

http://www.trichview.com/resources/clev ... client.zip

and faced strange problem..your demo can create and post html message with image embedded/attached but it gave error when tried to open received message which contains any type of image embedded/attached.Could you check and fix this ?

regards
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Please send a sample message to richviewgmailcom
bilgin
Posts: 2
Joined: Mon Nov 26, 2012 9:00 pm

Post by bilgin »

Dear Sergey

Here are the results which i got from your demo

sender Hotmail - receiver Gmail
text mail - ok
text mail with file attachment(not image) - ok
mail with image on background - error
mail with attachment (image file) - error

sender Gmail -receiver Hotmail
text mail - ok
text mail with file attachment(not image) - ok
mail with image on background - ok
mail with attachment (image file) - no attachment file visible

regards
bilgin
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I tried Gmail email with attached images, and I can reproduce this problem.
It happens because this image appears not in TclMailMessage.Attachments, but in TclMailMessage.Images.

This demo was created with quite an old version of CleverComponents, I contacted them to get a new version, may be this problem is already fixed.
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Well, they said it's not a bug but a feature: attached images are not included in Attachments, but included in Images, together with images embedded in HTML.
As for me, this is a very inconvenient decision, because we need to find a way to distinguish attached and embedded images ourselves. Of course, it is solvable, I'll update the demo soon.
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I uploaded a fixed version.
Additionally, it was changed for compatibility with TRichView 14.

If you will have problems (exceptions) when opening an email dialog, open RVFontCombos.pas (from RichViewActions) and change 3 lines

Code: Select all

  if RichViewEdit<>nil then begin
to

Code: Select all

  if (RichViewEdit<>nil) and (RichViewEdit.Style<>nil) then begin
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Updated.
Changes:
1) RVAControlPanel1 is placed on the email composing form. It is directly assigned to all actions on the form. The previous code did not work properly if another instance of TRVAControlPanel was already created.
2) clHTTP1 is placed on the email composing form, and assigned to RVAControlPanel1.clHTTP. So now this editor can download images when pasting RTF with links.
This feature requires RichViewActions to be compiled with support of CleverComponents, see http://www.trichview.com/help-actions/c ... onents.htm
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Updated: changed for compatibility with newer version of CleverComponents
xdbmw
Posts: 30
Joined: Sat Sep 24, 2011 11:31 pm

Post by xdbmw »

Are you sure that you have uploaded latest sources? I´m not able to compile MailClient Project in 10.1Berlin.
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Not, I am not sure. I'll contact the developers for the latest versions
xdbmw
Posts: 30
Joined: Sat Sep 24, 2011 11:31 pm

Post by xdbmw »

Sergey Tkachenko wrote:Updated.
So now this editor can download images when pasting RTF with links.
Does it also include incoming HTML e-mails (containing image links) in MailClient example? As far as I can see it doesn't but maybe I misunderstood something.
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Yes, this demo not only sends, but also receives HTML emails.
It uses RvHtmlViewImporter to load HTML in TRichViewEdit.

Please note that HTML email may contain images of 3 types:
1) (the most common way) included in the same email, encoded together with HTML in MIME format. This type of images is supported by this demo.

2) HTTP links to images. This type of images is supported if you compile RichViewActions with support of CleverComponents, and assign TRVAControlPanel.ClHTTP property.
I am not sure if this settings was done in the compiled demo.

3) Images embedded directly in HTML, directly in <img src>. This type of images is supported by newer version of RvHtmlViewImporter, the compiled demo was made before implementing this future.
xdbmw
Posts: 30
Joined: Sat Sep 24, 2011 11:31 pm

Post by xdbmw »

Sergey Tkachenko wrote:3) Images embedded directly in HTML, directly in <img src>. This type of images is supported by newer version of RvHtmlViewImporter, the compiled demo was made before implementing this future.
Do you have an example for receiving this type of emails? Maybe you can update your demo source in
http://www.trichview.com/resources/clev ... rdemos.zip
Thanks in advance.
Post Reply