Image problem with Outlook email

General TRichView support forum. Please post your questions here
Post Reply
MartinMCasey
Posts: 4
Joined: Mon Aug 08, 2016 2:49 pm

Image problem with Outlook email

Post by MartinMCasey »

Hi,
I downloaded the trail version last year, but the project was put on hold.
It is now active again.
I am sending HTML emails via SMTP and Outlook.
SMTP works fine, but there is a problem with Outlook - images get replaced by a placeholder icon.
As soon as I get this working the client will order the product.
Many thanks,
Martin

My Delphi7 code is as follows:

try
oMailItem := Outlook.CreateMailItem;
if assigned( oMailItem ) then
with oMailItem do
begin
MsgTo := cemail;
Subject := 'TEST';

clSMTP1.UserName := '[email protected]';
clSMTP1.Password := '********';

clMailMessage1.From.FullAddress := mainfrm.mainform.MUserSMTPEmailFromAddressComp;
clMailMessage1.ToList.EmailAddresses := EdtTo.Text;
clMailMessage1.Subject := 'TEST ' + EdtSubject.Text;}

Options := [rvsoNoHypertextImageBorders, rvsoImageSizes,
rvsoUseCheckpointsNames];
Stream := TMemoryStream.Create;
RichViewEdit1.SaveHTMLToStream(Stream, '', '', '', Options);
Stream.Position := 0;
SetLength(s, Stream.Size);
Stream.ReadBuffer(PRVAnsiChar(s)^, Length(s));

HTMLBody := s;

try
Send;
MessageSent := True;
except
on e: Sysutils.Exception do
MessageDlg('Mail send failure', mtWarning, [mbOK], 0)
end;
end; // with oMailItem do

finally
// etc
end;
MartinMCasey
Posts: 4
Joined: Mon Aug 08, 2016 2:49 pm

Outlook images issue...

Post by MartinMCasey »

Hi Sergei,
I'm thinking I'll need to parse the HTML and:
1. save the images as attachments
2. change the HTML tags to reflect what Outlook requires

For (1.), how do I access the original file names, so I can copy them to a temp folder, then reference the temp folder filename in the attachment.
When I look at the HTML, it just has the filename, not the path name.

Thanks,
Martin
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

As I can see, you use CleverComponents.
All this work is already implemented, see here: http://www.trichview.com/forums/viewtopic.php?p=30791

clRVSendMail.pas contains the function

Code: Select all

procedure SendHTMLEmail(RV: TCustomRichView; Smtp: TclSmtp; Msg: TclMailMessage;
  HTMLKind: THTMLKind = htmlAdvanced; Attachments: TStrings = nil);
procedure CopyHTMLEmailFromRVToMsg(RV: TCustomRichView; Msg: TclMailMessage;
  HTMLKind: THTMLKind = htmlAdvanced; Attachments: TStrings = nil);
SendHTMLEmail() takes content from RV, all other message properties from Msg, and send it using Smtp.
CopyHTMLEmailFromRVToMsg() fills the Msg content from RV.
MartinMCasey
Posts: 4
Joined: Mon Aug 08, 2016 2:49 pm

Post by MartinMCasey »

This doesn't help though.
The issue is with the HTML not working with Outlook.
I need a SendHTMLEmailViaOutlook(RV: TCustomRichView; etc...) that sorts out the image problems.
Can anybody help before I give up?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Unfortunately, we have only procedures that can send HTML emails that conform to HTML email standards. We do not have specific procedures for Outlook.
Post Reply