469,950 Members | 1,456 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

Sending an email using ASP

I hope someone can help me. I'm trying to setup an ASP page that will automatically send and email once the submit button is clicked. But my problem is that Lotus Notes is the email client and the script below is setup for Outlook to be the client. I've tried looking on the web but I can't seem to find anything that helps. Can anyone help me alter the code below so that it will work with Lotus Notes?

<%

if not IsEmpty(Request.Form("Send")) then
if Request.Form("SendTo") = "All" then
set RSEmails = conn.Execute("select EmpEmailAddress from I1BlastEmps")
elseif Request.Form("SendTo") = "Department" then
set RSEmails = conn.Execute("select EmpEmailAddress from I1BlastEmps " _
& "where Department = '" & Request.Form("DepartmentName") & "'")
else
set RSEmails = conn.Execute("select EmpEmailAddress from I1BlastEmps " _
& "where Role = '" & Request.Form("RoleName") & "'")
end if
set RSWhoForm = conn.Execute("Select EmpID, EmpEmailAddress from I1BlastEmps " _
& "where EmpID = " & Request.Form("EmpID"))
FromAddress = RSWhoForm("EmpEmailAddress")
do Until RSEmails.eof
set objMail = CreateObject("CDONTS.NewMail")
objMail.Send FromAddress,RSEmails("EmpEmailAddress"), _
cstr(Request.Form("Subject")),cstr(Request.Form("M essage"))
set objmail = nothing
RSEmails.MoveNext
loop
conn.Execute "Insert Into I1Blasts (EmpID, Subject, Message, WhenSent) values (" _
& "" & Request.Form("EmpID") & ", " _
& "'" & Request.Form("Subject") & "', " _
& "'" & Request.Form("Message") & "', " _
& "'" & Now() & "')"

TheMessage = "Message was sent!"
else
TheMessage = "Enter your message below"
end if

set RSDepartments = conn.Execute("select distinct Department from " _
& "I1BlastEmps order by Department")
set RSRoles = conn.Execute("select distinct Role from " _
& "I1BlastEmps order by Role")
set RSEmps = conn.Execute("select EmpID, EmpName from " _
& "I1BlastEmps order by EmpName")

%>
Feb 8 '07 #1
4 2088
devsusen
136 100+
do Until RSEmails.eof
set objMail = CreateObject("CDONTS.NewMail")
objMail.Send FromAddress,RSEmails("EmpEmailAddress"), _
cstr(Request.Form("Subject")),cstr(Request.Form("M essage"))
set objmail = nothing
RSEmails.MoveNext
loop
I think you should write Server.CreateObject instead CreateObject. You should write this statement outside of the loop, otherwise it will create object every for sending the mail.

The script will send mail using the SMTP server. In that case email client is not that important matter. Almost same sort of script worked for me. I found no problem with it.

susen
Feb 9 '07 #2
Thanks for the response susen. I'm able to create the objMail object just fine. But I'm getting the error "(0x80070003) /EmailBlast.asp, line 25". Line 25 is where I try to send the email. Using objMail.Send. How can I fix this?


set objMail = Server.CreateObject("CDONTS.NewMail")

do Until RSEmails.eof

objMail.Send FromAddress,RSEmails("EmpEmailAddress"), _
cstr(Request.Form("Subject")),cstr(Request.Form("M essage"))


set objmail = nothing
RSEmails.MoveNext
loop
Feb 9 '07 #3
devsusen
136 100+
Hi,

objMail.Send FromAddress,RSEmails("EmpEmailAddress"), _
cstr(Request.Form("Subject")),cstr(Request.Form("M essage"))
Please try writing this way -

Expand|Select|Wrap|Line Numbers
  1. objMail.From = FromAddress
  2. objMail.To = RSEmails("EmpEmailAddress")
  3. objMail.Subject = cstr(Request.Form("Subject"))
  4. objMail.Body = cstr(Request.Form("Message"))
  5. objMail.Send
You need to set the required attributes first and then call the Send function. I hope this will work for you.

Susen
Feb 13 '07 #4
clain
79
My dear friend CDONTS wont work anymore.. use new CDOSYS
here is the code



<%
dim too,from,message,subject
from=request.Form("txtTo")
too=request.Form("txtFrom")
subject=request.Form("textSubject")
message=request.Form("message")


'------------------------------Configuration-------------------
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = Server.CreateObject("CDO.Configuration")
cdoConfig.Fields.Item(sch & "sendusing") = 2
cdoConfig.Fields.Item(sch & "smtpserver") = "192.168.29.20"
cdoConfig.fields.update
'-------------------------------------------------------------
Set myMail=CreateObject("CDO.Message")
myMail.Configuration = cdoConfig
myMail.Subject=subject
myMail.From=from
myMail.To=too
myMail.TextBody=message
myMail.Send
set myMail=nothing
response.write("your mail has been send")

%>

Happy coding
Feb 19 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

13 posts views Thread by joe215 | last post: by
2 posts views Thread by kimberly.shaffer | last post: by
17 posts views Thread by Bonj | last post: by
3 posts views Thread by Ant | last post: by
6 posts views Thread by Anuradha | last post: by
4 posts views Thread by Roger Withnell | last post: by
10 posts views Thread by Markgoldin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.