TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rahul Sharma
NA
194
14.2k
GettingError while sending mail using C# code on Server
Jan 28 2018 1:39 AM
i am getting an error
Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
on shared hosting server but it worked fine on localhost
here is my code
using (MailMessage mail = new MailMessage())
{
mail.From = new MailAddress(emailFrom);
mail.To.Add(emailTo);
mail.Subject = subject;
mail.Body = body;
mail.IsBodyHtml = false;
message.Text = "Loading...";
SmtpClient smtp = new SmtpClient( "smtp.gmail.com", 587);
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Credentials = new System.Net.NetworkCredential("
[email protected]
", "password");
smtp.EnableSsl = true;
//smtp.UseDefaultCredentials = false;
smtp.Send(mail);
message.Text = "Message sent successfully....";
txtEmail.Text = "";
txtmsg.Text = "";
txtName.Text = "";
success.Visible = true;
Reply
Answers (
8
)
Looking for ASP .NET MVC Trainer
when call SqlDependency.Start(connectionString)