Ramesh.kbvr
Ramesh.kbvr

Reputation: 783

SmtpClient.Send attachment maximum size

I am trying to send attachment mails in asp.net pages using SmtpClient.Send() method. It is working fine with 2mb files. When i tried with 7mb attachment file, it is saying:

Failure sending mail.

What is the max size for sending mail using SmtpClient.Send(message) method. Why the above error coming.....?

Upvotes: 7

Views: 23947

Answers (4)

user9207271
user9207271

Reputation:

you can inc the size in config file

<configuration>
  <system.web>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0"/>
    <httpRuntime maxRequestLength="1048576" />
    <customErrors m

  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
    </security>
  </system.webServer>

Upvotes: 0

Bliminse
Bliminse

Reputation: 41

I just happened to come across this same error and I found this URL with useful information:

http://connect.microsoft.com/VisualStudio/feedback/details/544562/cannot-send-e-mails-with-large-attachments-system-net-mail-smtpclient-system-net-mail-mailmessage

Apparently there's a flaw in the .NET 4 Framework which makes mail sending fail whenever there's an attachment bigger than 3MB.

If you apply the patch provided on the link above you supposedly fix the problem.

Hope it was helpful

Upvotes: 4

Albin Sunnanbo
Albin Sunnanbo

Reputation: 47038

The documentation for SmtpClient or MailMessage does not say anything about size limits. Most likely this is enforced by your SMTP server. You should check your SMTP server configuration for size limits.

Upvotes: 10

Bhavik Goyal
Bhavik Goyal

Reputation: 2796

That depends upon your mail sending provider that is if you are using Gmail then it will be 10 MB.

This may also be happened if while attaching the file your connection had been interrupted.

Upvotes: 0

Related Questions