First of all the code I am going to provide is just the skelton of what you had mentioned in your posting.
Based on the following code I think you can build your code. The code lacks form validation and SMTP authentication,etc
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body><b>
Please note that this page lacks the form field validation.
<br>
If you want please provide the necessary client-side or server side form field validation<br>
In the To field enter the person's email addresses seperated by comma.
<br>I am assuming that everything goes well in this example<br>
</b>
<form name="f1" action="sendMail.asp" method="post">
From
<input type="text" name="from">
<br>
To
<input type="text" name="to"><br>
Subject
<input type="text" name="subject"><br>
<br>
Message
<textarea name="message" cols="30" rows="10"></textarea>
<br>
<input type="submit" name="submit" value="click">
</form>
</body>
</html>
Back end ASP file using which you are sending the mail in other words back end file of the above mentioned html page.
Code:
<%
Dim from,to,sub,message,toarr
from = Request.Form("from")
to = Request.Form("to")
sub = Request.Form("sub")
mesg = Request.Form("message")
if from = "" OR to = "" OR mesg ="" then
Response.redirect "error.html" 'error.html will display some kind of error message
end if
toarr = split(to,",") 'Now toarr contains all the to email addresses that were seperated by commas in it.
Dim toCount,i
toCount = UBound(toarr);
toCount = toCount - 1
Set myMail=CreateObject("CDO.Message")
Set objConn = Server.CreateObject ("CDO.Configuration")
Dim strSchemas
strSchemas = "http://schemas.microsoft.com/cdo/configuration/"
With objConn
.Fields(strSchemas & "smtpserver") = "mail.yoursmtpserver.com" 'Please specify your SMTP server information here
Fields(strSchemas & "smtpserverport") = 25
.Fields(strSchemas & "sendusing") = 2
.Fields(strSchemas & "smtpconnectiontimeout") = 60
.Fields.Update
End With
Set mymail.Configuration = objConn
myMail.MimeFormatted = true
myMail.From = from
myMail.Subject = sub
'HTML mail uncomment it if you need the following line and comment the text mail content line
myMail.HTMLBody = "<HTML><BODY><font face=verdana><table width=80% align=center><tr><td width=35% align=right><b>"& mesg &"</b></td></tr></table></font></BODY></HTML>"
'Text mail content
myMail.TextBody = mesg
For i = 0 To toCount
myMail.To=toarr(i)
myMail.Send
Next
Set myMail=nothing
%>
Please provide your SMTP server name within the ASP code.
Bookmarks