About System.Net.Mail.SmtpPermission

Hello everybody!

When I try to send an e-mail, the following error is displayed:

Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed

My code is:

Code:
                SmtpClient SmtpClient = new SmtpClient("mail.itesa.com.py", 587);
                System.Net.Mail.MailMessage Mail = new System.Net.Mail.MailMessage("[email protected]", "[email protected]");

                Mail.Body = Body;
                Mail.IsBodyHtml = true;
                Mail.Priority = MailPriority.High;
                Mail.Subject = "New message of " + FullName;

                SmtpClient.UseDefaultCredentials = false;
                SmtpClient.Credentials = new System.Net.NetworkCredential("UserName", "Password");


                SmtpClient.EnableSsl = false;
                SmtpClient.Send(Mail);


What could be the problem?
 
I would like to suggest to you please use port 25 instead of 587 then check it.
 
Back
Top