hi, please suggest me, i a ma coder, i am using the below code to mail in as.net my file is something like mail.aspx the code that i am using is <% @Page Language="C#" %> <% @Import Namespace="System.Web.Mail" %> <% string strTo = "christophw@fx2.Dev.AlfaSierraPapa.Com"; string strFrom = "webmaster@aspheute.com"; string strSubject = "Hi Chris"; SmtpMail.Send(strFrom, strTo, strSubject, "A real nice body text here"); Response.Write("Email was queued to disk"); %> but it not working!.. let me know do you have any idea..
Server Error in '/' Application. Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off". <!-- Web.Config Configuration File --> <configuration> <system.web> <customErrors mode="Off"/> </system.web> </configuration> Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL. <!-- Web.Config Configuration File --> <configuration> <system.web> <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/> </system.web> </configuration>
I have a fix for your code, for $5 if that's ok with you. <% @Page Language="C#" %> <% @Import Namespace="System.Web.Mail" %> <% String strTo = "christophw@fx2.Dev.AlfaSierraPapa.Com"; String strFrom = "webmaster@aspheute.com"; String strSubject = "Hi Chris"; /* SmtpMail.Send(strFrom, strTo, strSubject, "A real nice body text here"); */ MailMessage message = new MailMessage(); message.From = strFrom; message.To = strTo; message.Subject = strSubject; message.BodyFormat = MailFormat.Text; message.Body = "A real nice body text here"; try { message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", "smtp.gmail.com"); message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "465"); message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", "2"); message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","1"); message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "your_gmail_username@gmail.com"); message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "your_gmail_password"); message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true"); Response.Write("Sending outgoing message<br/>"); SmtpMail.Send(message); } catch(System.Web.HttpException exHttp) { Response.Write("Exception occurred: " + exHttp.Message + "<br/>"); } Response.Write("Email was queued to disk<br/>"); %>
i have got some help from Khalsait and fixed the issue, it was the missing of configure file, no issues with coding, thanks for your, suggestions,