hi Everyone,
i have a error in that Mail Coding,i try to send a Mail from aspx page using a Secure server but it provide a error while Uploading to a Server..
" the Error Is:"
Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
it is run in "Localhost" but not working in server..
i tried in many way.... here is my code...
and one more thing i have godaddy server.. Host:"secure server.net"
protected void btnSubmit_Click(object sender, EventArgs e)
{
string str = null;
str ="<table border='1'><tr><td>Email-ID:</td><td>" + txtEmailId.Text + "</td></tr><tr><td>Your Name:</td><td>" + txtname.Text + "</td><tr><td>Address:</td><td>" + txtaddress.Text + "</td></tr><tr><td>City:</td><td>" + txtcity.Text + "</td></tr><tr><td>State:</td><td>"+ txtstate.Text + "</td></tr><tr><td>Country:</td><td>" + txtcountry.Text + "</td></tr><tr><td>ZIPCode:</td><td>" + txtzipcode.Text + "</td></tr><tr><td>Phone No:</td><td>" + txtTelephoneNo.Text + "</td></tr><tr><td>Mobile No:</td><td>" + txtMobileNo.Text + "</td></tr><tr><td>Your Query:</td><td>" + txtYourQuery.Text + "</td></tr><tr><td>Your Comments:</td><td>" + txtComments.Text +"</td></tr></table>";
Response.Write(SendMail("example@gmail.com", "example@mydomain.com", "mymail@gmail.com", "Welcome to my page", str));
Response.Redirect("readex.aspx");
}
public string SendMail(string toList, string from, string ccList, string subject, string body)
{
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
SmtpClient smtpClient = new SmtpClient();
string msg = string.Empty;
try
{
MailAddress fromAddress = new MailAddress(from);
message.From = fromAddress;
message.To.Add(toList);
if (ccList != null && ccList != string.Empty)
message.CC.Add(ccList);
message.Subject = subject;
message.IsBodyHtml = true;
message.Body = body;
smtpClient.Host = "relay-hosting.secureserver.net";
smtpClient.Port = 25;
smtpClient.UseDefaultCredentials = true;
smtpClient.Credentials = new System.Net.NetworkCredential("example@mydomain.com", "mypassword");
smtpClient.EnableSsl = false;
smtpClient.Send(message);
msg = "Successful";
}
catch (Exception ex)
{
msg = ex.Message;
}
return msg;
1.smtpClient.Host = "smtpout.asia.secureserver.net" this is only working in my localhost.. but it providing a error after uploading server..
2.relay-hosting.secureserver.net.... it not working in both localhost and also server..
3. smtpClient.EnableSsl = false; disable a ssl not working in localhost
smtpClient.EnableSsl = true; enable is working in local host...
above is my coding i want to know how to send a mail in my own domain name with smtp..
is any way to send that mail...? or what problem/Missed in my coding ?...please Answer ASAP...!!!