Hi Bart,
I tried including a TMemo in my app as you suggested and got better results. However, upon further analysis, I found that there is a problem with sending an email with an HTML body to a GMail address using Cloud Pack 3.8.8.0. Most of the formatting is no longer showing up. The same email sent to an Outlook address comes through just fine.
Here is the HTML code I'm testing with (it's a bit long):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>
</title>
</head>
<body>
<p style="text-align:left;margin:0pt 0pt 0pt 0pt;line-height:1.15;text-indent:0pt;"><span style="font-size:11pt;font-weight:normal;color:#000000;background-color:transparent;font-style:normal;font-family:Calibri;">st</span><span style="font-size:11pt;font-weight:normal;color:#000000;background-color:#FFFF00;font-style:normal;font-family:Calibri;">rhtrhr</span><span style="font-size:11pt;font-weight:normal;color:#000000;background-color:transparent;font-style:normal;font-family:Calibri;">th</span></p><p style="text-align:left;margin:0pt 0pt 0pt 0pt;line-height:1.15;text-indent:0pt;"><span style="font-size:20pt;font-weight:normal;color:#FF0000;background-color:transparent;font-style:normal;font-family:Calibri;">10</span><span style="font-size:20pt;font-weight:normal;color:#FF0000;background-color:transparent;font-style:normal;font-family:Calibri;"><sup>2</sup></span></p><p style="text-align:left;margin:0pt 0pt 0pt 0pt;line-height:1.15;text-indent:0pt;"><span style="font-size:11pt;font-weight:normal;color:#000000;background-color:transparent;font-style:normal;font-family:Calibri;">str</span><span style="font-size:11pt;font-weight:bold;color:#00B050;background-color:transparent;font-style:normal;font-family:Calibri;">hsrth</span><span style="font-size:11pt;font-weight:normal;color:#000000;background-color:transparent;font-style:normal;font-family:Calibri;">srthsrt</span><span style="font-size:16pt;font-family:Calibri;color:#0000FF;background-color:transparent;text-decoration: underline;font-style:italic;font-weight:bold;">hsth eth</span><span style="font-size:11pt;font-weight:normal;color:#000000;background-color:transparent;font-style:normal;font-family:Calibri;">eth reeh</span></p></body>
</html>
Here is our original code as it has been for over a year:
mGMailMessage := AdvGMail.Mails.Add;
mGMailMessage.ToRecipients.Add(teToEmail.Text);
mGMailMessage.CCRecipients.Add(teCCEmail.Text);
mGMailMessage.BCCRecipients.Add(teBCCEmail.Text);
mGMailMessage.Subject := editSubject.Text;
mGMailMessage.MessageType := mtHTML;
sHTMLFileName := 'c:\users\Robert\work\htmlfile.html';
ADocument := RichEditControl.Document;
ADocument.SaveDocument(sHTMLFileName, TdxRichEditDocumentFormat.html);
mGMailMessage.Body := HTMLFile.ReadAllText(sHTMLFileName);
AdvGMail.Files.Clear;
for iCount := 0 to lbAttachments.Count-1 do
begin
AdvGMail.Files.Add.FileName := lbAttachments.Items.Strings[iCount];
end;
bMailSent := AdvGMail.SendMessage(mGMailMessage);
I modified my code to include a TMemo - I added the following code after the line mGMailMessage.Body := HTML...
Memo1.Text := '';
mGMailMessage.Body := '';
Memo1.Text := HTMLFile.ReadAllText(sHTMLFileName);
for iCount := 0 to Memo1.Lines.Count - 1 do
begin
mGMailMessage.Body := mGMailMessage.Body + Memo1.Lines[iCount];
mGMailMessage.Body := mGMailMessage.Body + sLineBreak;
end;
What's happening is this - using a version of our application compiled in June, I tested sending the HTML body with and without an attachment to both GMail and Outlook email addresses. Everything worked correctly.
I ran the same code that was working in June but now is compiled with Cloud Pack 3.8.8.0 and sent the same HTML body with and without an attachment to both GMail and Outlook email addresses. The emails without the attachment look correct. The emails with an attachment contained no body. This is true for emails to both Outlook and GMail email addresses.
I ran the new code version in which I ran the HTML body through a TMemo as you suggested. I sent the same HTML body with and without an attachment to both GMail and Outlook email addresses. The emails sent to the Outlook address look correct. The emails sent to the GMail addresses included the body but almost all of the HTML formatting was gone - no different colors, no different font sizes, no bold or underlining - only superscripts or subscripts appeared.
This all worked fine before I upgraded to Cloud Pack 3.8.7.1. I'm puzzled as to why GMail would react so differently now. I'm also curious as to why I now need a TMemo when this has been working for a year or two without it.
Thanks,
Robert Jackson