In this article I will explain with an example, how to resolve the following error while sending email with attachment from Network Drive (Shared Folder) in SQL Server.
Attachment file \\Share\Employees\Customers.csv is invalid.
\\Share\Employees\Customers.csv is the location of the file from where attachment is made.
This article is applicable to following SQL Server versions i.e. 2008, 2008R2, 2012, 2014, 2016, 2017, 2019 and 2022.
 
 

Error

The following error occurs while sending email with attachment from Share Folder (Directory) in SQL Server.
sp_send_dbmail error while attaching Network file in SQL Server
 
 

Cause

This error occurs because the sp_send_dbmail Stored Procedure is not able to access the file or the file is not present in the specified location.
 
 

Solutions

Following are the solution to resolve this problem.
1. The Network location you are trying to use cannot be accessed due to wrong IP Address. Thus make sure the IP Address that you are trying to access is correct.
2. Make sure any Firewall is not blocking.
3. The user that executes the SQL Server service has Read access to the Network location.
4. Make sure you are connected to the LAN network.