Login  
Search All Forums
Dart Home | PowerTCP Mail for .NET | Custom Development Reply | PowerTCP Mail for .NET Topics | Forums   
AuthorForum: PowerTCP Mail for .NET
Topic: Empty message body
pvestuto

From: Kildeer, IL USA
Posts: 44
Member Since: 07/03/01
posted September 3, 2009 1:55 PM

I have an application that sends emails with a message body or not, and 0-N attachments. We're having an issue where a user sends out an email with a PDF attachment, no message body. Their email system provides a disclaimer which gets added to the body of the email when it goes out. The receipient cannot read the PDF as it appears corrupt. If we go ahead and add an empty message body using the following code, it works:

  .Parts.Simple.Add(New MessagePartStream((New System.Text.ASCIIEncoding).GetString(<byte array>), ContentType.TextPlain, ContentEncoding.QuotedPrintable, "ISO-8859-1"))

We do have code that checks if no message body and no attachments are included (e.g, just sending a subject). In that condition, we do the following:

        If .Parts.Simple.Count = 0 And .Attachments.Count = 0 Then
          .Text = ""
        End If

Should we always set .Text="" if .Parts.Simple.Count = 0? Is there a better approach for setting the body so email systems that add disclaimers don't corrupt the attachments?

thanks,

 - Paul -
Jason Farrar (Admin)

From: Oneida, NY USA
Posts: 223
Member Since: 07/24/07

Extra Support Options
Custom Application Development

posted September 8, 2009 1:19 PM

Your proposed solution of setting the Text property to "" when the Parts.Simple.Count property is 0 is acceptable there really isn't any other way to do it. Ideally the process attaching the disclaimer would check the content-type and if there is no body on a message create one as it is perfectly valid to send an E-mail without a body.

------
-Non-current subscribers must contact sales@dart.com to update subscription and receive continued support as needed.
------

pvestuto

From: Kildeer, IL USA
Posts: 44
Member Since: 07/03/01
posted September 10, 2009 3:15 PM

We are now testing the modified code which sets .Text = "" if .Parts.Simple.Count = 0.
This sets an empty body and we attach one PDF attachment.

The result is a second attachment that is empty (for example ATT16794.dat). Why is an attachment being added when we were trying to set the message body?

I can send the trace information if that would help.

 - Paul -
pvestuto

From: Kildeer, IL USA
Posts: 44
Member Since: 07/03/01
posted September 10, 2009 7:24 PM

It appears that instead of this:
          .Text = ""

This following code sends a message with an empty body and only the one PDF attachment that is expected:

          .Parts.Simple.Add(New MessagePartStream((New System.Text.ASCIIEncoding).GetString((New System.Text.ASCIIEncoding).GetBytes("")), ContentType.TextPlain, ContentEncoding.QuotedPrintable, "ISO-8859-1"))

Any comments on the difference, or any recommended practices?

thanks,

 - Paul -
Reply | PowerTCP Mail for .NET Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX