Page 1 of 1

Image problem with Outlook email

Posted: Mon Aug 08, 2016 5:30 pm
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 := 'martin@futurelinkpublishing.co.uk';
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;

Outlook images issue...

Posted: Tue Aug 09, 2016 9:33 am
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

Posted: Tue Aug 09, 2016 1:26 pm
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.

Posted: Wed Sep 07, 2016 9:51 am
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?

Posted: Wed Sep 07, 2016 11:07 am
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.