Home All Groups Group Topic Archive Search About

MailMessage message size

Author
21 Apr 2010 8:43 AM
Eric
Hi,

I'm working on a ASP.Net website where I use the MailMessage method to send
a report filled in by the user to a given email address.
The user can also upload an attachement to be put in the data part of the
report.

If the attachement is less then 1,7 Mb there is no problem, the email is sent.
Any larger attachement and I get an error stating "the message could not be
sent"

The webserver is an IIS7 and I use the local smtp server (via IIS6) to send
the emails.
In the settings of the smtp server I have unchecked the email size
limitations. At first I had it set to 8192 Kb, but for testing I removed the
limit.

Unfortunalty the emails are not sent, I don't even see them appear in the
mailroot/queue folder. (the smaller emails I do see)

I have put the timout property of the SmtpClient to 300 secs, so it should
have enough time to send the message.

What is going wrong here?

Dim smtpC As SmtpClient

    Dim message As New MailMessage
    message.To.Add(New MailAddress(rc.sEmailOntvanger))
    message.From = New MailAddress(rc.sEmailZender)
    message.Subject = "RIE report for site " & rc.sSitenummer
    message.Body = strbody.ToString
    message.BodyEncoding = System.Text.Encoding.Unicode
    message.IsBodyHtml = True

    message.Attachments.Add(data1)
    data1 = Nothing

    'attach PDF file to message
    Dim RapportPDFName As String = Server.MapPath("~\") &
FormFile.Replace("/", "\")
    data1 = New Attachment(RapportPDFName, MediaTypeNames.Application.Octet)
    Try
      ' Add time stamp information for the file.
      disposition1 = data1.ContentDisposition
      disposition1.CreationDate =
System.IO.File.GetCreationTime(RapportPDFName)
      disposition1.ModificationDate =
System.IO.File.GetLastWriteTime(RapportPDFName)
      disposition1.ReadDate = System.IO.File.GetLastAccessTime(RapportPDFName)
    Catch ex As Exception
      ClientScript.RegisterStartupScript(Me.GetType(), "alert",
"<script>alert('Error');</script>")
      message.Dispose()
      data1 = Nothing
      disposition1 = Nothing
      Exit Sub
    End Try
    message.Attachments.Add(data1)
    data1 = Nothing


    smtpC = New SmtpClient("localhost", 25)
    smtpC.UseDefaultCredentials = False
    smtpC.DeliveryMethod = SmtpDeliveryMethod.Network
    smtpC.Timeout = 300000

    Try
      smtpC.Send(message)
      message.Dispose()
      disposition1 = Nothing
      data1 = Nothing
    Catch ex As Exception
      message.Dispose()
      disposition1 = Nothing
      data1 = Nothing
      ClientScript.RegisterStartupScript(Me.GetType(), "alert",
"<script>alert('Het was niet mogelijk om het rapport te emailen. -1-" +
smtpC.Host + "');</script>")
      Exit Sub
    End Try

rg,
Eric

Author
26 Apr 2010 10:55 PM
kevinp
You may be doing everything just right, but the email server you're
sending it to is rejecting it because of the size (not your email
server--the recipient's). Nothing you can do on your end other than
send smaller files.


On Wed, 21 Apr 2010 01:43:02 -0700, Eric
<E***@discussions.microsoft.com> wrote:

Show quoteHide quote
>Hi,
>
>I'm working on a ASP.Net website where I use the MailMessage method to send
>a report filled in by the user to a given email address.
>The user can also upload an attachement to be put in the data part of the
>report.
>
>If the attachement is less then 1,7 Mb there is no problem, the email is sent.
>Any larger attachement and I get an error stating "the message could not be
>sent"
>
>The webserver is an IIS7 and I use the local smtp server (via IIS6) to send
>the emails.
>In the settings of the smtp server I have unchecked the email size
>limitations. At first I had it set to 8192 Kb, but for testing I removed the
>limit.
>
>Unfortunalty the emails are not sent, I don't even see them appear in the
>mailroot/queue folder. (the smaller emails I do see)
>
>I have put the timout property of the SmtpClient to 300 secs, so it should
>have enough time to send the message.
>
>What is going wrong here?
>
> Dim smtpC As SmtpClient
>
>    Dim message As New MailMessage
>    message.To.Add(New MailAddress(rc.sEmailOntvanger))
>    message.From = New MailAddress(rc.sEmailZender)
>    message.Subject = "RIE report for site " & rc.sSitenummer
>    message.Body = strbody.ToString
>    message.BodyEncoding = System.Text.Encoding.Unicode
>    message.IsBodyHtml = True
>
>    message.Attachments.Add(data1)
>    data1 = Nothing
>
>    'attach PDF file to message
>    Dim RapportPDFName As String = Server.MapPath("~\") &
>FormFile.Replace("/", "\")
>    data1 = New Attachment(RapportPDFName, MediaTypeNames.Application.Octet)
>    Try
>      ' Add time stamp information for the file.
>      disposition1 = data1.ContentDisposition
>      disposition1.CreationDate =
>System.IO.File.GetCreationTime(RapportPDFName)
>      disposition1.ModificationDate =
>System.IO.File.GetLastWriteTime(RapportPDFName)
>      disposition1.ReadDate = System.IO.File.GetLastAccessTime(RapportPDFName)
>    Catch ex As Exception
>      ClientScript.RegisterStartupScript(Me.GetType(), "alert",
>"<script>alert('Error');</script>")
>      message.Dispose()
>      data1 = Nothing
>      disposition1 = Nothing
>      Exit Sub
>    End Try
>    message.Attachments.Add(data1)
>    data1 = Nothing
>
>  
>    smtpC = New SmtpClient("localhost", 25)
>    smtpC.UseDefaultCredentials = False
>    smtpC.DeliveryMethod = SmtpDeliveryMethod.Network
>    smtpC.Timeout = 300000
>
>    Try
>      smtpC.Send(message)
>      message.Dispose()
>      disposition1 = Nothing
>      data1 = Nothing
>    Catch ex As Exception
>      message.Dispose()
>      disposition1 = Nothing
>      data1 = Nothing
>      ClientScript.RegisterStartupScript(Me.GetType(), "alert",
>"<script>alert('Het was niet mogelijk om het rapport te emailen. -1-" +
>smtpC.Host + "');</script>")
>      Exit Sub
>    End Try
>
>rg,
>Eric