SmtpMail delivers incomplete body

  • Thread starter Thread starter Edwin G. Castro
  • Start date Start date
E

Edwin G. Castro

I'm using the System.Web.Mail.SmtpMail class to send email from an app
I wrote. I needed to install IIS to get it to send the messages even
though I wanted to use an existing SMTP server. Anyway, I got it to
send messages for me which is great.... Unfortunately, I do not
receive the complete contents of the Body. I have ran a few tests to
see what the Body contained before and after the SmtpMail.Send() call
and they matched. Something down the line messed it up so that only
part of the message is delivered. Any help would be very much
appreciated! Thanks!
 
I'm using the System.Web.Mail.SmtpMail class to send email from an app
I wrote. I needed to install IIS to get it to send the messages even
though I wanted to use an existing SMTP server. Anyway, I got it to
send messages for me which is great.... Unfortunately, I do not
receive the complete contents of the Body. I have ran a few tests to
see what the Body contained before and after the SmtpMail.Send() call
and they matched. Something down the line messed it up so that only
part of the message is delivered. Any help would be very much
appreciated! Thanks!

I ran a few more tests and I discovered that when I write the body
contents to a file (body.html) that all the contents are there as
expected. If I open the file (body.html) in Visual Studio .NET I get
some interesting results. The first result is that when I first view
the file in Design mode I see all the contents as expected. When I
switch to HTML mode Visual Studio .NET automaticaly formats the file
and I loose the end of the file just like when I receive the messages
through email. If I swith back to Design mode after the file has been
formated then I can't see the end of the file.

It looks like .NET is performing a similar kind of formatting since
the result is exactly the same.
 
I'm using the System.Web.Mail.SmtpMail class to send email from an app
I wrote. I needed to install IIS to get it to send the messages even
though I wanted to use an existing SMTP server. Anyway, I got it to
send messages for me which is great.... Unfortunately, I do not
receive the complete contents of the Body. I have ran a few tests to
see what the Body contained before and after the SmtpMail.Send() call
and they matched. Something down the line messed it up so that only
part of the message is delivered. Any help would be very much
appreciated! Thanks!

I determined the cause of the problem.

The file I was reading to generate my email from contained '\x0'
characters. Microsoft tools generate the file and I was not aware of
that. In any case, those characters were causing SmtpMail to think the
end of the body had arrived. I added a simple call to
string.Trim('\x0') to remove the offending characters and the problem
is now solved!
 
Back
Top