I have problem with code of contact form for server using asp.NET 1.1, unfortunately upgrade of .NET is not possible. This code worked perfectly up to today. There was some change with the server and I have no idea what happened. My only guess is that I don't have permission for localhost anymore. Is there a possibility to change the way how it is sent on .NET 1.1? I tried by using gmail account, but I only got errors because of SSL and ports.
My code:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Mail" %>
<script runat="server">
void btnSubmit_Click(Object sender, EventArgs e) {
MailMessage objEmail = new MailMessage();
objEmail.To = "my_mail@gmail.com";
objEmail.From = txtFrom.Text;
objEmail.Cc = txtCc.Text;
objEmail.Subject = "Contact";
objEmail.Body = "Message: " + txtComments.Text + " <br> " + "name:" + txtName.Text;
objEmail.Priority = MailPriority.High;
objEmail.BodyFormat = MailFormat.Html;
// Make sure you have appropriate replying permissions from your local system
SmtpMail.SmtpServer = "localhost";
try{
SmtpMail.Send(objEmail);
}
catch (Exception exc){
}
}
</script>
After removing try/catch method:
Source error:
Line 16: // Make sure you have appropriate replying permissions from your local system
Line 17: SmtpMail.SmtpServer = "localhost";
Line 18: SmtpMail.Send(objEmail);
Line 19:
Line 20: }
Stack trace:
[COMException (0x80040213): Nie powiodlo sie polaczenie warstwy transportu z serwerem.
]
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0
System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) +473
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +58
[HttpException (0x80004005): Could not access 'CDO.Message' object.]
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +113
System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1569
System.Web.Mail.SmtpMail.Send(MailMessage message) +150
ASP.div_aspx.btnSubmit_Click(Object sender, EventArgs e) in e:\helm\www2\wspolnicy.com\wwwroot\div.aspx:18
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1273
User contributions licensed under CC BY-SA 3.0