System.web.mail truncating message body - strange behaviour ??

Discussion in 'ASP .Net' started by Jitesh Sinha, Dec 5, 2003.

  1. Jitesh Sinha

    Jitesh Sinha Guest

    Hi,

    I am running Windows 2003/ IIS 6.0. I was stuck with rather a abnormal
    behaviour of System.Web.mail class. It was truncating the message body
    after 3,071 character. The code i was testing was:

    Import Namespace="System.Web.Mail"
    Dim aa as new StringBuilder(600010)
    Dim i as Integer

    For i = 1 to 60000
    aa = aa.Append("a")
    next

    aa = aa.Append("end")


    Dim objMailMessage As New MailMessage
    objMailMessage = New MailMessage
    'send mail
    TRY
    With objMailMessage
    .To = ""
    .From = ""
    .Subject = "Test Webmail"
    .BodyFormat = MailFormat.Text
    .Body = len(aa.Tostring()) & "--" & aa.Tostring()
    End With

    SmtpMail.Send(objMailMessage)
    CATCH
    response.write (err.description)
    END TRY

    response.write ("<br><br>" & aa.Tostring() & "<br>end<br>")

    I modified the settings of IIS SMPT and removed all the constraints. I
    also checked with my incoming POP server. I checked with Classic ASP
    and everything work fine.

    I even tried setting the BodyEncoding property of the mailMessage
    object to different options but to no avail.

    I just inserted CHR(10) at the position where it was truncating and IT
    WORKED.

    I still could not figure out the logical reason behind it. Anyone here
    could throw some light on it ??

    Regards.
    Jitesh Sinha
     
    Jitesh Sinha, Dec 5, 2003
    #1
    1. Advertising

  2. I've had a similar problem with textboxes on windows forms, using the
    AppendText method. Text would get truncated after 3000 something
    characters. I managed to get around this by appending the Text property -
    i.e. using textBox1.Text += "Some Text" as opposed to
    textBox1.AppendText("Some Text"). It's a less efficient way to do things,
    but it stopped the strings from being truncated.

    It appears that the StringBuilder class has a similar problem...

    Mun




    "Jitesh Sinha" <> wrote in message
    news:...
    > Hi,
    >
    > I am running Windows 2003/ IIS 6.0. I was stuck with rather a abnormal
    > behaviour of System.Web.mail class. It was truncating the message body
    > after 3,071 character. The code i was testing was:
    >
    > Import Namespace="System.Web.Mail"
    > Dim aa as new StringBuilder(600010)
    > Dim i as Integer
    >
    > For i = 1 to 60000
    > aa = aa.Append("a")
    > next
    >
    > aa = aa.Append("end")
    >
    >
    > Dim objMailMessage As New MailMessage
    > objMailMessage = New MailMessage
    > 'send mail
    > TRY
    > With objMailMessage
    > .To = ""
    > .From = ""
    > .Subject = "Test Webmail"
    > .BodyFormat = MailFormat.Text
    > .Body = len(aa.Tostring()) & "--" & aa.Tostring()
    > End With
    >
    > SmtpMail.Send(objMailMessage)
    > CATCH
    > response.write (err.description)
    > END TRY
    >
    > response.write ("<br><br>" & aa.Tostring() & "<br>end<br>")
    >
    > I modified the settings of IIS SMPT and removed all the constraints. I
    > also checked with my incoming POP server. I checked with Classic ASP
    > and everything work fine.
    >
    > I even tried setting the BodyEncoding property of the mailMessage
    > object to different options but to no avail.
    >
    > I just inserted CHR(10) at the position where it was truncating and IT
    > WORKED.
    >
    > I still could not figure out the logical reason behind it. Anyone here
    > could throw some light on it ??
    >
    > Regards.
    > Jitesh Sinha
     
    Munsifali Rashid, Dec 5, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?bWc=?=

    Size of e-mail message - message.Body = msgText

    =?Utf-8?B?bWc=?=, Feb 10, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    573
    Chad Z. Hower aka Kudzu
    Feb 11, 2004
  2. =?Utf-8?B?TXJGZXo=?=

    Mail message size problem (System.Web.Mail)

    =?Utf-8?B?TXJGZXo=?=, Mar 14, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    644
    =?Utf-8?B?TXJGZXo=?=
    Mar 14, 2005
  3. Brad
    Replies:
    2
    Views:
    10,319
  4. =?Utf-8?B?QWxleCBNYWdoZW4=?=

    System.Net.Mail vs System.Web.Mail

    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Jun 16, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    10,619
    Walter Wang [MSFT]
    Jun 16, 2006
  5. Nathan Sokalski
    Replies:
    5
    Views:
    921
    Spam Catcher
    Dec 12, 2006
Loading...

Share This Page