Hey ya all,
OK I used a asp.net e-mail script from: http://www.4guysfromrolla.com/webtech/080801-1.shtml
Now most the scripts if looked at on the web use similar code to this, only problem is I am using Microsoft Visual Web Developer 2005 Express Edition and it tells me the script is mostly out of date. So I had a go at updating it and for the most part I think I got it. However obviously their is a problem, firstly I don’t no how to set the SmtpMail.host to use a default one, in the old script you just used SmtpMail.SmtpServer = "" but in the new script it can't be blank. I also not sure what the mail format should be, I set it to IsBodyHtml = False as their isn’t a MailFormat.Text equivilant. Encase your wondering I have tried to get the old script to work but got lots of errors like: <identity impersonate="true"/> error which I managed to fix in the web.config file only to then get a allowDefinition='MachineOn
ly' beyond machine.config. error message for witch I couldn’t fix. So rather than waist time trying to fix it I updated the code and no longer get errors like that so the code is working just need to set it up correctly. My code:
<%@ Page Language="VB" AutoEventWireup="true" Debug="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
er as Object, e as EventArgs)
' Create an instance of the MailMessage class
Dim objMM As New System.Net.Mail.MailMessag
' Get the reply address from the web page form
Dim ad As New System.Net.Mail.MailAddres
' Set the a varible to be used in defining the SmtpClient what ever the smeg that is !?
Dim SmtpMail As New System.Net.Mail.SmtpClient
' Set the properties - send the email to me
' Set the reply addess to the e-mail address of who ever filled out the form
objMM.From = ad
' Send the email in text format .... well can't do that in the new code as don't no how so just set it as not html unless you want to have html!?
objMM.IsBodyHtml = False
' Set the priority - options are High, Low, and Normal
objMM.Priority = System.Net.Mail.MailPriori
' Set the subject
objMM.Subject = "4GuysFromRolla.com - Feedback"
' Set the body ...BNo idea if the body part is ok as not sure what this vbCrLf ment to do quite
objMM.Body = "At " + DateTime.Now + " feedback was sent from an ASP.NET " & _
"Web page. Below you will find the feedback message " & _
"send by " & txtName.Text & "." & vbCrLf & vbCrLf & _
----" & vbCrLf & vbCrLf & _
txtMessage.Text & vbCrLf
' Specify to use the default Smtp Server ...ok so how do you set this to a defualt one ?
SmtpMail.Host = ""
' Now, to send the message.....if i ever get this far that is !
panelSendEmail.Visible = false
panelMailSent.Visible = true
<asp:panel id="panelSendEmail" runat="server">
<form id="Form1" runat="server">
<h2>We are interested in your feedback! Please enter the following
requested information below to send us your comments.</h2>
<asp:textbox id="txtName" runat="server" />
<b>Your Email Address:</b>
<asp:textbox id="txtEmail" runat="server" />
<asp:textbox id="txtMessage" TextMode="MultiLine"
Columns="40" Rows="10" runat="server" />
<asp:button runat="server" id="btnSendFeedback" Text="Send Feedback!"
<asp:panel id="panelMailSent" runat="server" Visible="False">
An email has been sent to the email address you specified. Thanks!
Any help is welcome