[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Sending Mail Script

Posted on 2001-08-09
9
Medium Priority
?
348 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 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

656 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