Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7836807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:19:24+00:00 2026-06-02T14:19:24+00:00

i have to send mail with attachments.my code works only for files smaller than

  • 0

i have to send mail with attachments.my code works only for files smaller than 4mb.
I have already checked everything on net but everyone suggest the same soolution.That is to change httpruntime attributes in webconfig which i have already done.

<httpRuntime maxRequestLength="10000" executionTimeout="1500"  />

i have changed everything that has “timeout” attribute in web config.Also made a change in KeepAlive in application configuration in IIS but even after doing all this changes the problem still remain in my application.everytime i try to upload files larger than 4mb the connection timeout after exactly 1.5 minutes.

Code in click event

protected void btnSend_Click(object sender, EventArgs e)
        {
            MailMessage msg = new MailMessage();
            SmtpClient smtp = new SmtpClient();
            string strFrom = txtFrom.Text;
            string strTo = txtTo.Text;
            string strSubject= ddlTemplate.SelectedItem.Text.ToString();
            string strBody =txtBody.Text;
            string strCC =txtCC.Text;
            string strBCC =txtBCC.Text;
            if (this.fuAttachments.HasFile)
            {
                Attachment at = new Attachment(fuAttachments.PostedFile.InputStream,fuAttachments.PostedFile.ContentType);

                at.ContentDisposition.FileName = this.fuAttachments.FileName;
                msg.Attachments.Add(at);


            }
           smtp.EnableSsl = true;

            msg.From = new MailAddress(strFrom);
            msg.To.Add(strTo);
            msg.Subject = strSubject;
            msg.Body = strBody;

            //smtp = new SmtpClient("localhost");
            //smtp.UseDefaultCredentials = true;

            try 
            {
                smtp.Send(msg);
            }
            catch (SmtpException Ex)
            {

                throw;
            } 

            if (msg.Attachments.Count > 0)
            {
                //Clear the attachments and delete the sessionid folder from tempFiles 
                msg.Attachments.Dispose();
            }

        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T14:19:27+00:00Added an answer on June 2, 2026 at 2:19 pm

    I have found the culprit in my application.It is smtp client’s timeout property that was stopping the process after around 1.5minutes.Default value for this property is 100 seconds which i changed to 1500 seconds(1500000ms as this property takes values in ms) and successfully mailed with attachment.

    smtp.Timeout = 1500000;
    

    see this for more info.

    by the way i tested it with 21mb attachment.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written some code in my VB.NET application to send an HTML e-mail
I have written ASP.Net code to send mails from domain1.com mail account such as
I have built a php mail system. now I want to also send attachments
I could send mail from my Activity when i have already configured with any
I have an App that will send authenticated emails using System.Net.Mail and System.Net.NetworkCredential my
I have the following code which works fine, but it doesn't send the attachment
I have some code used to send emails. It works on windows but when
i have function to send mail with attachment to microsoft exchange server. My problem
I have send an email using php mailer class. mail was sending successfully but
I am trying to send mail via SMTP in Perl. I have written a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.