Forum Moderators: open
All I need to do is have the mail form send to more than one address. How do I list more than one mail server and more than one address?
Script follows
--------------------------------
<%Set mailer = Server.CreateObject("ASPMAIL.ASPMailCtrl.1")
recipient = "name@whatever.com"
sender = Request.Form("First")
subject = "Form email here"
message = message & "TEXT BOX NAME OF FORM 1" & Request.Form("ONE")&chr(10)&chr(13)
message = message & "TEXT BOX NAME OF FORM 2 " & Request.Form("TWO")&chr(10)&chr(13)
message = message & "TEXT BOX NAME OF FORM 3" & Request.Form("THREE")&chr(10)&chr(13)
message = message & "TEXT BOX NAME OF FORM 4" & Request.Form("FOUR")&chr(10)&chr(13)
message = message & "TEXT BOX NAME OF FORM 5" & Request.Form("FIVE")&(",")&Request.Form("SIX")&chr(10)&chr(13)
message = message & "Comment / Question: " & Request.Form("MESSAGE OF FORM")&chr(10)&chr(13)
message = message &chr(10)&chr(13)
message = message &chr(10)&chr(13)
mailserver = "mail.whatever.com"
result = mailer.SendMail(mailserver, recipient, sender, subject, message)
%>
<% If "" = result Then %>
<%=Request.Form("NAME")%><p><font size="2" face="Arial">
GENERIC THANK YOU MESSAGE HERE</font></p>
<% Else %><font face="Arial" size="2"> </font>
<font face="Arial" size="2">Your e-mail was not sent.
Please e-mail us directly, at
email@whatever.com.
Error message: <%= result %>
</font>
<p> </p>
<p> </p>
<p>
<% End If %>
-G
PS (I know *nothing* about ASP, so if you could point me to some good resources, I'd appreciate that too.)
<%
sender = "joe@company.com" 'could be extracted from a form
subj = "email subject" 'could be extracted from a form
bod = "generic body of email" 'could be extracted from a form
footer = "generic ending to email" 'could be extracted from a form
Dim fname(5000), sname(5000), uname(5000), agency(5000), pass(5000)
Dim regsys, userfile
Set regsys = CreateObject("Scripting.FileSystemObject")
varUserfile = Server.MapPath("emaillist.txt")
Set userfile = regsys.OpenTextFile(varUserfile,1)
Do While Not userfile.AtEndOfStream
data = userfile.ReadLine
'if you wish to include the recipients name as well as their email address use a symbol to seperate the date, in this case: $#. if you only wish to include the address, the next 3 lines are unnecessary
temp = Split(data,"$#")
recipadd = temp(0) 'assuming that the email address is first, and the name second in the text file
recipname = temp(1)
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = "host.host.host" ' Specify a valid SMTP server
Mail.From = sender
Mail.AddAddress recipadd, recipname
Mail.Subject = subj
Mail.Body = bod & Chr(13) & Chr(13) & footer
Mail.Send
On Error Resume Next
Mail.SendToQueue
Set Mail = Nothing
Loop
userfile.close
%>
the text file would look something like this:
joe.smith@email.com$#Joe Smith
jammydodger@email.com$#Bill Hudson
rosy@email.net$#Rose Arden
hope this helps
You can simply use a semi-colon separated list of email addresses to send to, and it will take care of it. The CDONTS send command is described here: [msdn.microsoft.com ]
I originally posted the basic form for the CDONTS send command here: [webmasterworld.com ]
I am confused. When you say "that script won't work", which script are you referring to?
Then, do I use the semi colon separated list with the first script or the second?
-G
To send mail use this:
Dim cdonts
Set cdonts = Server.CreateObject("CDONTS.NewMail")
Call cdonts.Send("from@domain.com","to1@domain1.com;to2@domain2.com;to3@domain3.com", "this is a subject", "this is a body", 1)
Set cdonts = Nothing
I'll send you a complete example of an email form by sticky.