Hi @Rahul Polaboina ,
Please try below T-SQL;
Declare @filenames varchar(max)
Set @filenames = '\\Testfiles\Test1.csv;\\Testfiles\Test2.csv'
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Mod',
@from_address = '******@modisglobal.com',
@recipients= '******@gmail.com',
@subject= 'Test Email',
@body = @body1,
@file_attachments = @filenames;
Or
DECLARE @filenames varchar(max)
DECLARE @file1 VARCHAR(MAX) = '\\Testfiles\Test1.csv'
SELECT @filenames = @file1
-- Optional new attachments
DECLARE @file2 VARCHAR(MAX) = ';\\Testfiles\Test2.csv'
DECLARE @file3 VARCHAR(MAX) = ';\\Testfiles\Test3.csv'
-- Create list from optional files
SELECT @filenames = @file1 + @file2 + @file3
-- Send the email
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Mod',
@from_address = '******@modisglobal.com',
@recipients= '******@gmail.com',
@subject= 'Test Email',
@body = @body1,
@file_attachments = @filenames;
Quote from MS document.
[ @Gaydamak _attachments = ] 'file_attachments' Is a semicolon-delimited list of file names to attach to the e-mail message. Files in the list must be specified as absolute paths. The attachments list is of type nvarchar(max). By default, Database Mail limits file attachments to 1 MB per file.
Windows does not allow SQL Server to provide credentials from a remote computer to another remote computer. Therefore, Database Mail may not be able to attach files from a network share in cases where the command is run from a computer other than the computer that SQL Server runs on.
If the response is helpful, please click "Accept Answer" and upvote it, as this could help other community members looking for similar thread.