this morning my application developed in C# ASP.NET has a problem that has never occurred before
this application stores the filename within the column of a database
when it comes time to send the attachment via email, the application looks for the file name and attaches it to the message
the application cannot find the attached files on the physical path of the server even if these files are correctly present and block sending an email with attachment
the error is
The system cannot find the file specified 'C:\inetpub\wwwroot\public\newfile.pdf'
the file newfile.pdf
instead it is located inside the public folder
how to do resolve this?
my simplified code below
List<string> listofattachments = new List<string>();
using (OdbcDataReader reader = cmd.ExecuteReader())
{
if (reader.HasRows)
{
while (reader.Read())
{
listofattachments.Add(reader["attachment"].ToString());
}
}
}
foreach (string attachments in listofattachments)
{
if (!string.IsNullOrEmpty(attachments))
{
mailMessagePlainText.Attachments.Add(new Attachment(@"C:\\inetpub\\wwwroot\\public\\" + attachments.Trim().ToString())); //line of error
}
}