Hi,
i have hosted my website in godaddy windows server and i have used following codes for sending email using gmail
string myEmailAddress = "enquirefusion@gmail.com";
string mypwd = "******";
string toEmailAddress = "sanjay@fusiontechnopower.com";
string subject = Txtsubject.Text;
string mailbody = txtname.Text+"\n"+Txtemail.Text+"\n"+Txtbody.Text;
var client = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587)
{
Credentials = new System.Net.NetworkCredential(myEmailAddress, mypwd),
EnableSsl = true
};
client.Send(myEmailAddress, toEmailAddress, subject, mailbody);
But i am getting a runtime error on the line
var client = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587)
Error says:
Security Exception
Description: 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.Net.Mail.SmtpPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Please help me guys i am in great trouble...god bless you