5
Answers

Sending mail along with attachment on my hosting server problem

Ask a question
tekk

tekk

14y
3.9k
1
hi friend,

I created a website and uploading into my hosting server. In that sending mail along with attachment on my hosting server. but i getting following error;

Parser Error Message: This configuration section cannot be used at this path.  This happens when the site administrator has locked access to this section using <location allowOverride="false"> from an inherited configuration file.

Source Error:

Line 25:             during development.
Line 26: -->
Line 27: <trust level="Medium"/>

Let me cleared my side what i done;

Am using VS 2008, asp.net 2.0 and sending mail using System.net.mail name space. here my code:
using System.Net.Mail;
              
MailMessage objEmail = new MailMessage();
objEmail.To.Add(txtTo.Text.ToString());
objEmail.From = new MailAddress("[email protected]");
objEmail.Subject = "User Account Details";
objEmail.Body = "Your User Account was created";
objEmail.Priority = System.Net.Mail.MailPriority.High;
objEmail.IsBodyHtml = true;
 
string strFileName = null;
if (FileUpload1.PostedFile != null)
{
HttpPostedFile attFile = FileUpload1.PostedFile;
int attachFileLength = attFile.ContentLength;
if (attachFileLength > 0)
      { 
                strFileName = FileUpload1.PostedFile.FileName;
                Attachment attFilename = new Attachment(strFileName);
               objEmail.Attachments.Add(attFilename);
       }
SmtpClient smtpclient = new SmtpClient();
try
{
smtpclient.Send(objEmail);
Response.Write("successfully sent");
}
catch (Exception ex)
{
Response.Write("send failure:" + ex.ToString());
}

My webconfig setting:
<system.net>
    <mailSettings>
      <smtp>
        <network host="www.computertekk.com" usernm="xxx" pwd="xxx"/>
      </smtp>
    </mailSettings>
  </system.net>
 
<system.web>
     ...
    <trust level="Full" />
    ...
<authentication mode="Windows"/>
    ...
   </system.web>


I checked in localhost its working fine and also on my server mail was going successfully but only thing is mail along with attachment is getting problems. please help me. its to urgent

Thanks in advance

Rajiv

Answers (5)