SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
Attachment data = new Attachment(@"\\MYPC\Share\FinalReport.html");
message.Attachments.Add(data);
smtpClient.Send(message);
This Code has worked fine for the last week. But today I got an exception as it could not find file: \MYPC\Share\FinalReport.html. I tried for an hour in different ways then I restarted my system. Again its Worked fine.
Key point: I didn’t shutdown or restart my PC for the past week.
Not much to go on with your question really, however, if I had to guess I would say it’s probably an issue with your network access. It looks as though your accessing the file on a network share so if you are losing connection at some point that would explain the
FileNotFoundException. It’s not uncommon for network access to become “unavailable” at peak times i.e. when your network is at it’s busiest.