Issue in TAdvGMail

Today I decided to upgrade to version 3.8.7.1 and I had problems sending messages through TAdvGMail.

If the email has an attached file the message text is not sent if it has more than 300 bytes.

Follow the procedure below to see this problem:

1) Compile and run the ..\GMailDemo\GMailDemo.pdr
2) In the "To" field, enter your email address
3) In the field "Messsage" type a message with more than 300 bytes
4) Attach a PDF file
5) Send message
6) Open your email program and you will see that the message text was not received

This issue was introduced in version 3.8.5.0 of the Cloud Pack (I also tested with 3.8.6.0 and 3.8.7.0  and had same problem).


In version 3.8.4.2 this issue does not occur.

Hi,


Thank you for notifying.
This issue has been fixed and the update will be available with the next release of TMS VCL Cloud Pack.
Hello, are you sure this issue is corrected?

We just installed v3.8.8.0 and the same problem seems to exist.  If we send an email with an attachment, the body text is not included, regardless of the length of the text string.  If we send an email without an attachment the body text is included.

One thing that might be contributing to the issue is that we are sending the body text as formatted HTML, not just plain text.  However, everything was working properly and we haven't changed our source code in over a year.  The only change has been an update to version 3.8.8.0 of the TMS cloud pack.

This is a critical issue for us because our users can no longer trust our application to send email via Gmail.

Thanks,

Mike

I have re-tested the GMailDemo by sending a email with attachment and HTML body text and haven't noticed any issues.


Can you please make sure any files from previous installs have been removed from your machine?
Does the issue also occur in GMailDemo or only in your own application?
Does the issue occur with any kind of attachment and/or any kind of HTML body text or only with specific content?
Hi Bart - I'll check it and get back to you.  Thanks for the quick reply.

Hi Bart,

I checked the application and here's what I found:

The body text is coming from a RichEdit control (TdxRichEditControl from DevExpress) as formatted HTML...

<!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;">This is a test of the body of the email.</span></p></body>
</html>

When there is an attachment, the body text is not included.

When there is not an attachment, the body text is included.

As I mentioned earlier, this issue just started with 3.8.8.0, so it appears to be related to the formatted HTML.

The GMailDemo works correctly, but that demo is using a simple TMemo for the body text and not a RichEdit control.

I don't see any files from previous installs on my machine.

Thanks,

Mike

Hi Mike,


I still haven't been able to reproduce the issue.
Unfortunately we don't have access to the TdxRichEditControl.
I've tried sending an HTML formatted email with attachment that has the sample HTML you provided as the body text and the email arrived with the body text intact problems.

As you mentioned the GMailDemo is working as expected, I'm assuming the issue must be related to your own application.
Can you please check what you are doing differently compared with the GMailDemo?
Have you tried including a TMemo in your app to see if that changes the incorrect behaviour?

Hi Bart,


I can send HTML of any size and it gets through just fine - unless I add an attachment.

I've tested this with your demo and it LOOKS like it works with HTML but that's because you are using a TMemo for the body and TMemo doesn't do HTML.  Try replacing the TMemo with a component that allows you to format HTML and send with an attachment.  Or... add HTML code in the .pas file for the body and try it that way... might/should work.

This all worked fine before I upgraded to Cloud Pack 3.8.7.1.

Thanks,
Robert Jackson


Hi Robert,


This post was replied to via email.
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

I can confirm that I have been able to reproduce an issue where the html formatting is not applied for emails viewed in GMail while the formatting is displayed as expected when viewing the exact same email in Outlook.


Recently some changes where implemented in TAdvGMail to improve the handling of special characters in the email body. It's  possible that these changes have caused the unexpected behavior you are seeing.

We are currently investigating what the exact cause of the issue is and how it can be fixed.

Hi Bart,


I was wondering if there has been any progress on restoring HTML capabilities to emails sent to GMail accounts with TADVGmail?

Thanks,
Robert Jackson

Hi Robert,


My tests with the TAdvGMail source from before the changes made in July showed the same results as with the current version.
The HTML sample you provided is displayed as expected in Outlook and without HTML formatting in GMail.

I can only assume this issue is caused by recent changes in the GMail reader which we have no control over.

If you send an email to mailto:info@tmssoftware.com I can provide the source for TAdvGMail from before the changes so yo can try this out yourself if you wish.

Hi Bart,


HTML formatting in GMail currently works fine if I run a version of my application compiled in June (before I upgraded to Cloud Pack 3.8.7.1).  

I tested that.  The GMail reader reads that correctly, but reads incorrectly later HTML versions from the current version of TAdvGMail.

This isn't making sense.

Thanks, 
Robert Jackson

I'm not sure what is causing this issue.


Would it be possible to provide the following data so I can further investigate this?
- A forward of both a mail message that is displaying correctly and one that is not.
- The original source of both emails. In GMail click the top right menu (three dots), select Show Original then select Download Original.

You can mail the files to mailto:help@tmssoftware.com

Hi Bart,


In the current 3.8.8.2 version, TAdvGMail sends HTML correctly to a GMail address if there is no attachment - but if an attachment is included, the body of the email seems to be suppressed.

How is the inclusion of an attachment managing to affect the GMail reader in this way?

Thanks, 
Robert Jackson

Hi Robert,


The GMail API expects a different structure for email messages sent with or without attachment.
We are currently investigating these issues and will report back as soon as possible.