1 Replies - 1739 Views - Last Post: 18 October 2011 - 07:01 AM Rate Topic: -----

#1 creative-rose  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 20-January 11

limit the maximum size of file attachment and display error massege

Posted 08 October 2011 - 01:15 AM

Hello every body :flowers:
I design the contact form
but i face one problem
it is when attachment the file i want to limit the size of file to 20 mb only
and i do it in web.config
this code:
 <location>
	<system.web>
		<httpRuntime executionTimeout="240" maxRequestLength="20000"/>
		<customErrors mode="RemoteOnly">
		</customErrors>
		<compilation debug="true"/></system.web>
  </location>
	<system.web>


and in the vb file i do this code
    'Attach file using FileUpload Control and put the file in memory stream
        If FileUpload1.HasFile Then
           
            mail.Attachments.Add(New Attachment(FileUpload1.PostedFile.InputStream, FileUpload1.FileName))



            If (FileUpload1.PostedFile.ContentLength) > 20000 Then
                MsgBox("Your attachment is larger than the maximum limit for attachments.")



            End If
        End If


but when attache the file that is more than 20 mb display error page "the web page is not available"

i want your help as soon as possible
Thank you


Is This A Good Question/Topic? 0
  • +

Replies To: limit the maximum size of file attachment and display error massege

#2 hemantwithu  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 31
  • Joined: 18-October 11

Re: limit the maximum size of file attachment and display error massege

Posted 18 October 2011 - 07:01 AM

This issue is confirmed to be a bug (attachments larger than 3,050,417 bytes encounter this issue), and currently, there is no workaround solution, if this issue is urgent, please contact support directly (http://support.microsoft.com).

This issue is discussed at Microsoft Connect, I attach its link here for people who may interested in it:
Cannot send E-Mails with large attachments (System.Net.Mail.SmtpClient, System.Net.Mail.MailMessage)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1