I have a .msg file already present on the server, which I need to open.
I am using the following code
protected void lnkDelvMail_Click(object sender, EventArgs e)
{
string chkViewstate = ViewState["DelvMailPath"].ToString();
if (chkViewstate == "")
{
Response.Write("<script>alert('File Not Uploaded');</script>");
}
else
{
try
{
var process = new Process();
string strFilePath = Server.MapPath(ViewState["DelvMailPath"].ToString());
process.StartInfo = new ProcessStartInfo()
{
UseShellExecute = true,
FileName = strFilePath
};
process.Start();
}
catch (Exception ex)
{
Response.Write("<script>alert('File cannot be found on the server');</script>");
}
}
}
It opens the file first time properly in outlook but,
when I close the web application and open it again and then try to access the same file
it gives the following error
Cannot open msg file. The file may not exist, you may not have permission to open it, or it may be open in another program.
Right-click the folder that contains the file, and then click Properties to check your permissions for the folder.
Also When I upload the .msg file onto the server and save it there
it is not saved properly. All the contents of the file is blank.
How do i avoid this and open the file every time from my web app.
thanks in advance.