hi friends,
I am using .Net framework 3.5 and Microsoft VS 2008,
here's the scenario:
Am sending mail with attachment from my hosting server, I get securityexception error. but app works fine on my local machine but whenever I try to run it from my hosting server, I get following errors:
---------------------------------------------------------------------------------------------------------------------------------------------------------
Security ExceptionDescription:
The application attempted to perform an operation not allowed by the
security policy. To grant this application the required permission please
contact your system administrator or change the application's trust level in the
configuration file.
Exception Details:
System.Security.SecurityException: Request for the permission of type
'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
----------------------------------------------------------------------------------------------------------------------------------------------------------
Here my code:
MailMessage objEmail = new MailMessage();
objEmail.To.Add(txtemail.Text.ToString());
objEmail.From = new MailAddress("
[email protected]");
objEmail.Subject = "User Account Details";
objEmail.Body ="Your User Account was created as a " ;
objEmail.Priority = System.Net.Mail.MailPriority.High;
objEmail.IsBodyHtml = true;
string strFileName = FileUpload1.PostedFile.FileName;
Attachment attFilename = new Attachment(strFileName);
objEmail.Attachments.Add(attFilename);
SmtpClient smtpclient = new SmtpClient();
smtpclient.Send(objEmail);
For uploading purpose am using "FileUplaod control" and SMTP Server mention in webconfig.
Please Help me, Thanks in Advance
Regards,
Tekk