Page 1 of 2

Making HTML email client with CleverComponents

Posted: Sun Sep 12, 2010 9:45 am
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)

Posted: Tue Oct 18, 2011 7:06 pm
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)

Compiled demo is not working correctly !

Posted: Mon Nov 26, 2012 9:06 pm
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

Posted: Tue Nov 27, 2012 10:15 am
by Sergey Tkachenko
Please send a sample message to richviewgmailcom

Posted: Tue Nov 27, 2012 8:06 pm
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

Posted: Sun Dec 02, 2012 9:36 am
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.

Posted: Tue Dec 25, 2012 1:44 pm
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.

Posted: Tue Dec 25, 2012 2:34 pm
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

Posted: Sun Jul 07, 2013 3:21 pm
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

Posted: Tue Aug 09, 2016 1:22 pm
by Sergey Tkachenko
Updated: changed for compatibility with newer version of CleverComponents

Posted: Wed Aug 10, 2016 4:32 pm
by xdbmw
Are you sure that you have uploaded latest sources? I´m not able to compile MailClient Project in 10.1Berlin.

Posted: Wed Aug 10, 2016 5:39 pm
by Sergey Tkachenko
Not, I am not sure. I'll contact the developers for the latest versions

Posted: Thu Sep 15, 2016 12:18 pm
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.

Posted: Fri Sep 16, 2016 8:34 am
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.

Posted: Wed Oct 19, 2016 8:08 am
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.