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:
---------------------------------------------------------------------------------------------------------------------------------------------------------
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
Replies
Know the answer? Post it — somebody with the same question will find it here.