Mail message attachement problem

E

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
 
A

Andrew Morton

Eric said:
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)

Have you tried from an ordinary email client, like Outlook Express, to
narrow down the problem area? Maybe it'll give you an error code which is
more specific than "the message could not be sent".
http://www.ietf.org/rfc/rfc0821.txt lists the error codes.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,968
Messages
2,570,149
Members
46,695
Latest member
StanleyDri

Latest Threads

Top