未加星标

SQL Server Database Mail Attachment Error

字体大小 | |
[数据库(mssql) 所属分类 数据库(mssql) | 发布者 店小二04 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏
Problem

We setup SQL Server Database Mail and use it to send alerts via email. We recently received the following error "File attachment or query results size exceeds allowable value of 1000000 bytes." when sending an attachment in the email. How can this be fixed?

Solution

Here is an example of trying to send a large Excel file and getting the error message "file attachment or query results size exceeds allowable value".

EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'test',
@recipients = N'test@test.com',
@subject = 'Large Attachment Error',
@body = '',
@file_attachments = 'largefile.xls'

When this code runs, it returns the following error:


SQL Server Database Mail Attachment Error
Check SQL Server Database Mail Settings

We can check the SQL Server Database Mail parameter properties by running the following stored procedure: sysmail_help_configure_sp .

exec msdb.dbo.sysmail_help_configure_sp

This stored procedure returns the SQL Server Database Mail parameters and parameter values.


SQL Server Database Mail Attachment Error
Change SQL Server Database Mail Settings with Management Studio

We can also check the settings using SQL Server Management Studio (SSMS). Go to Management > Database Mail and right click and select Configure Database Mail. Select Next until you get to the Select Configuration Task screen and select View or change system parameters and select Next.


SQL Server Database Mail Attachment Error

Here we can see the current setting for Maximum File Size (Bytes) . The default is 1,000,000 bytes which is 1MB. The maximum value we can use 2,147,483,647, which is roughly 2GB. If we try to use a value greater than 2147483647 it will throw an error. So change the value to the necessary size for your needs.


SQL Server Database Mail Attachment Error

Another option that we can change is the Prohibited Attachment File Extensions . This will allow us to block specific file extensions as attachments.


SQL Server Database Mail Attachment Error
Change SQL Server Database Mail Settings with T-SQL

We can also change these parameter values using sysmail_configure_sp as follows.

exec msdb.dbo.sysmail_configure_sp 'MaxFileSize','2000000'
exec msdb.dbo.sysmail_configure_sp 'ProhibitedExtensions','exe,dll,vbs,js,ps' Next Steps Read these additional tips aboutDatabase Mail. Last Update: 1/3/2017

本文数据库(mssql)相关术语:熊片数据库 mssql数据库 oracle数据库 pubmed数据库 access数据库 万方数据库

主题: SQLSQL ServerExcel2G
分页:12
转载请注明
本文标题:SQL Server Database Mail Attachment Error
本站链接:http://www.codesec.net/view/520052.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 数据库(mssql) | 评论(0) | 阅读(34)