File attachment or query results size exceeds allowable value of 1000000 bytes

We are used SQL Server Database for sending emails. When try to send email with large attachment it received the following error “File attachment or query results size exceeds allowable value of 1000000 bytes.”

Understanding the Error

Before diving into the solution, let’s grasp why this error occurs. This error typically surfaces when you’re dealing with file attachments or querying large datasets in your C# application, and the size exceeds the predetermined limit of 1000000 bytes (approximately 976.6 KB).

Troubleshooting Steps

Here’s a breakdown of steps you can take to troubleshoot and fix this error:

1. Review File Attachments

Firstly, review the file attachments in your C# application. Check if there are any large files being attached that might be surpassing the size limit. Optimize or compress these files if possible to bring them within the allowable limit.

2. Optimize Query Results

If you’re encountering this error while querying data, consider optimizing your queries. Refine your queries to fetch only the necessary data, avoiding unnecessary bulk that might lead to size exceedance.

3. Implement Paging

Implement paging in your queries to retrieve data in smaller chunks rather than fetching everything at once. This not only helps in avoiding size limitations but also enhances performance by fetching data on demand.

4. Increase Size Limit

If optimizing files and queries isn’t feasible or sufficient, consider increasing the allowable size limit. However, exercise caution with this approach, as excessively large attachments or query results can impact performance and scalability.

5. Error Handling

Implement robust error handling mechanisms in your C# application to gracefully handle scenarios where size limits are exceeded. Provide informative error messages to users and log detailed information for debugging purposes.

6. Monitor Resource Usage

Regularly monitor resource usage in your C# application to identify any anomalies or potential bottlenecks. This proactive approach can help in preemptively addressing issues before they escalate.

7. Consult Documentation

Consult the documentation of the libraries or frameworks you’re using in your C# application. They may provide specific guidelines or recommendations for handling large data sets or file attachments.

Solution: Query results size exceeds

Re-Config SQL Database Mail Setting

Step 1 : Right click Database Mail and select the “Configure Database Mail” and

             Click “Next”

Query results size exceeds Configure Database Mail
Configure Database Mail

Step 2 : Select the Highlighted option and click “Next”

Configure Task
Configure Task

Step 3 : Change the hilighted value and click “Next”

             Default value is “1000000” change it what is you requirement

Configure System Parameters
Configure System Parameters


By following these troubleshooting steps and best practices, you can effectively resolve the “File Attachment or Query Results Size Exceeds Allowable Value of 1000000 Bytes” error in your C# application. Remember to optimise your file attachments and queries, implement error handling, and stay vigilant with resource monitoring. With these strategies in place, you’ll be back on track with your C# projects in no time.