S
Santosh
Hii i am writting following code for attaching file to the emails it
runs well on the local server but when i run it on domain servert then
it gives an error Access to the path is denied.
can any one tell me what is the problem in it.
public void AttachFilesToEmail(object sender, System.EventArgs e)
{
DataTable dt;
dt = attachedFileTable();
string strFile_Name;
int attachFile_Length;
//if(attachFile_Length==1
if (attachFile1.PostedFile.ContentLength > 0)
{
HttpPostedFile attFile1 = attachFile1.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length > 0)
{
strFile_Name = Path.GetFileName(attachFile1.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFile_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFile_Length).ToString()+
" Bytes");
}
}
if (attachFile2.PostedFile.ContentLength > 0)
{
HttpPostedFile attFile1 = attachFile2.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length > 0)
{
strFile_Name = Path.GetFileName(attachFile2.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFile_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFile_Length).ToString()+
" Bytes");
}
}
if (attachFile3.PostedFile.ContentLength > 0)
{
HttpPostedFile attFile1 = attachFile3.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length > 0)
{
strFile_Name = Path.GetFileName(attachFile3.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFile_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFile_Length).ToString()+
" Bytes");
}
}
if (attachFile4.PostedFile.ContentLength > 0)
{
HttpPostedFile attFile1 = attachFile4.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length > 0)
{
strFile_Name = Path.GetFileName(attachFile4.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFile_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFile_Length).ToString()+
" Bytes");
}
}
if (attachFile5.PostedFile.ContentLength > 0)
{
HttpPostedFile attFile1 = attachFile5.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length > 0)
{
strFile_Name = Path.GetFileName(attachFile5.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFile_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFile_Length).ToString()+
" Bytes");
}
}
runs well on the local server but when i run it on domain servert then
it gives an error Access to the path is denied.
can any one tell me what is the problem in it.
public void AttachFilesToEmail(object sender, System.EventArgs e)
{
DataTable dt;
dt = attachedFileTable();
string strFile_Name;
int attachFile_Length;
//if(attachFile_Length==1
if (attachFile1.PostedFile.ContentLength > 0)
{
HttpPostedFile attFile1 = attachFile1.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length > 0)
{
strFile_Name = Path.GetFileName(attachFile1.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFile_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFile_Length).ToString()+
" Bytes");
}
}
if (attachFile2.PostedFile.ContentLength > 0)
{
HttpPostedFile attFile1 = attachFile2.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length > 0)
{
strFile_Name = Path.GetFileName(attachFile2.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFile_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFile_Length).ToString()+
" Bytes");
}
}
if (attachFile3.PostedFile.ContentLength > 0)
{
HttpPostedFile attFile1 = attachFile3.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length > 0)
{
strFile_Name = Path.GetFileName(attachFile3.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFile_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFile_Length).ToString()+
" Bytes");
}
}
if (attachFile4.PostedFile.ContentLength > 0)
{
HttpPostedFile attFile1 = attachFile4.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length > 0)
{
strFile_Name = Path.GetFileName(attachFile4.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFile_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFile_Length).ToString()+
" Bytes");
}
}
if (attachFile5.PostedFile.ContentLength > 0)
{
HttpPostedFile attFile1 = attachFile5.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length > 0)
{
strFile_Name = Path.GetFileName(attachFile5.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFile_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFile_Length).ToString()+
" Bytes");
}
}