[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Sending Mail Script

Posted on 2001-08-09
9
Medium Priority
?
349 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
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 400 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
Industry Leaders: 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month20 days, 6 hours left to enroll

872 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