Solved

Sending Mail Script

Posted on 2001-08-09
9
339 Views
Last Modified: 2012-05-04
I am using the folloiwng script to send results from an email form. What I would like to do is:

 - have the email sent to more then one address
 - have the email sent to a third address using the CC email field

<%

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.RemoteHost = "relay.mysite.com"
Mailer.FromAddress = Request.Form("FromAddress")
Mailer.AddRecipient"Info","info@mysite.com"
Mailer.Subject    = Request.Form("Subject")
strMsgHeader = "Form Information Follows: " & vbCrLf
for i = 1 to Request.Form.Count
  strMsgInfo = strMsgInfo & Request.Form.Key(i) & " - " &  Request.Form.Item(i) & vbCrLf
next
strMsgFooter = vbCrLf & "End of form information"
Mailer.BodyText = strMsgHeader & strMsgInfo & strMsgFooter


if Mailer.SendMail then
Response.Redirect("thankyou.asp")

else
Response.Redirect("error.asp")

end if
%>
0
Comment
Question by:ASCAN
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 3

Expert Comment

by:CyberSoft
ID: 6368016
ASCAN,

Is there any reason why you've opted to use a third party mailer instead of using built in CDO in IIS because CDO supports the multiple email addresses in the TO and CC fields

See: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdo/html/_denali_newmail_object_cdonts_library_.asp

CyberSoft

PS: Respond here if you want some example code using CDO.
0
 
LVL 7

Accepted Solution

by:
John844 earned 100 total points
ID: 6368337
to add multiple recipients I believe that you can just repeat the next line changing the name and email for each new person.
Mailer.AddRecipient"Info","info@mysite.com"

to add the cc recipient, there should be a method similar to the one above, maybe AddCCRecipient.  I don't have that component for reference currently.

John
0
 
LVL 7

Expert Comment

by:John844
ID: 6368359
to add a CC recipient just add a line like

Mailer.AddCC "somename", "someemail.email.com"
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 33

Expert Comment

by:hongjun
ID: 6368593
John844 is correct.

hongjun
0
 
LVL 7

Expert Comment

by:John844
ID: 6368612
thanks for the confirmation hongjun
John
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6368724
For me I am not sure about the component used but for most of the components in the market I know, the algorithm is like that. So I presume that should also be like this. Perhaps, your user manual will tell you more.

hongjun
0
 
LVL 1

Expert Comment

by:bahu_m
ID: 6370306
To send email to multiple users you have to keep adding the users using AddRecipient method. For CC use AddCC method. Check the following code:


Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.RemoteHost = "relay.mysite.com"
Mailer.FromAddress = Request.Form("FromAddress")

Mailer.AddRecipient "Info","info@mysite.com"
Mailer.AddRecipient "Info1","info1@mysite.com"
Mailer.AddRecipient "Info2","info2@mysite.com"
Mailer.AddCC "ccname", "ccname@mysite.com"

Mailer.Subject    = Request.Form("Subject")
strMsgHeader = "Form Information Follows: " & vbCrLf
for i = 1 to Request.Form.Count
     strMsgInfo = strMsgInfo & Request.Form.Key(i) & " - " &  Request.Form.Item(i) & vbCrLf
next
strMsgFooter = vbCrLf & "End of form information"
Mailer.BodyText = strMsgHeader & strMsgInfo & strMsgFooter
if Mailer.SendMail then
     Response.Redirect("thankyou.asp")
else
     Response.Redirect("error.asp")
end if
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6370720
bahu_m, that's what John had commented.

hongjun
0
 

Expert Comment

by:pinkstonm
ID: 13212889
Are these statements for CDO?

Mailer.AddRecipient "Info","info@mysite.com"
Mailer.AddRecipient "Info1","info1@mysite.com"
Mailer.AddRecipient "Info2","info2@mysite.com"
Mailer.AddCC "ccname", "ccname@mysite.com"
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help with query 3 42
Query still returning duplicates 5 59
CREATE DATABASE 3 45
GitHub 1 39
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question