73548

Detecting file size before sp_send_dbmail

Question:

We're using the following with a 10MB limit for attachments.

EXEC msdb..sp_send_dbmail @recipients = 'me@me.co.uk', @subject = 'foo bar', @file_attachments = 'C:\xxx\yyy\myFile.xlsx, @body_format = 'html', @body = 'norf';

Is it possible in the SQL Server scripts to check the size of myFile.xlsx before running this script?

Answer1:

I have a solution by using Batch Files:

<strong>[C:\FileSize.cmd]</strong>

@echo %~z1

Now you can get size of <your_file> by using that file:

DECLARE @t table(filesize int) INSERT INTO @t EXEC [xp_cmdshell] @command_string = 'C:\filesize.cmd <your_file>' SELECT TOP(1) * FROM @t

Recommend

  • Grails unit test verify mock method called
  • mysql what is the right syntax for this conditional update statement
  • Writing a unix daemon
  • How can I read in multiple excel files in SPSS using a macro?
  • Formula in Excel that references another Excel file based on cell reference
  • Excel Range in C# using interop.Excel. Range both empty and not empty?
  • ssh2_scp_send() using php corrupts pdf
  • git push origin master denied to user X where x is NOT the user in the local git config
  • Where does the file get saved using “File file = new file(filename)” in Android
  • How to trick Node.js to load .js files as ES6 modules?
  • Floating-point number in Excel
  • How to convert integer to string and get length of string
  • python: forcing relative imports to search from script file
  • Bad interaction between Zope2 XML-RPC and AT Image mutator?
  • Python 3.2.2, error(scripts to exe)
  • Blackberry 6: how to detect a long click on track pad?
  • How to pass nginx proxy url for socket
  • Why isn't obj.style.left = “200px”; working in this code?
  • Can't remove headers after they are sent
  • How to convert SOAP response with xsi values to json in WSO2esb
  • saving file generated by TCPDF
  • Alternative To body {overflow:scroll;} That Will Prevent Page Jostling/Wriggling?
  • Test if a set exists before trying to drop it
  • Play WS (2.2.1): post/put large request
  • How to create a file in java without a extension
  • How to avoid particles glitching together in an elastic particle collision simulator?
  • Recording logins for password protected directories
  • Splitting given String into two variables - php
  • Resize panoramic image to fixed size
  • Volusion's generic SQL folder, functionality
  • Check if a string to interpolate provides expected placeholders
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • How to get icons for entities from eclipse?
  • Proper way to use connect-multiparty with express.js?
  • Load html files in TinyMce
  • How do you join a server to an Active Directory (domain)?
  • coudnt use logback because of log4j
  • Append folder name and increment by 1 using batch script
  • JaxB to read class hierarchy
  • How to Embed XSL into XML