View Full Version : Sending email with ASP


hassaan
03-22-2006, 03:39 AM
I am using the following code to send email with ASP but I get an error which says:

Server.CreateObject Failed

emailsend.asp, line 5



<%
For Each x In Request.Form
message = "my message"
Next
set smtp=Server.CreateObject("Bamboo.SMTP")
smtp.Server="webmail.mywebsite.com"
smtp.Rcpt="receiver@hisdomain.com"
smtp.From="webmaster@mydomain.com"
smtp.FromName="Webmaster"
smtp.Subject="Test Mail"
smtp.Message = message
on error resume next
smtp.Send
if err then
response.Write err.Description
else
Response.redirect ("http://mywebsite.com")
end if
set smtp = Nothing
%>


Help please!!!!

Kodo
03-22-2006, 04:18 AM
That usually means that the object hasn't been installed on the server you're trying to create it from or you're object reference is incorrect.

hassaan
04-28-2006, 08:16 AM
This is the new code i used:

<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Test Mail Subject"
myMail.From="webmaster@mydomain.com"
myMail.To="receiver@domain.com"
myMail.Bcc="receiver@domain.com"
myMail.TextBody="This is a message."
myMail.Send
set myMail=nothing
%>


I get an error on executing this file that myMail.Send failed (line 8)
I asked my webhosting compnay, they said that they support CDOSYS used in this code, howver for coding issues, ask someone specific.
Please help!!!!

Kodo
04-28-2006, 02:03 PM
when in asp you must use server.createobject

Set myMail=Server.CreateObject("CDO.Message")

hassaan
04-29-2006, 12:40 AM
Thanks a loT!!!

well i did add server to that - made it server.createobject

now i get a new error - it says:
The "SendUsing" configuration value is invalid. (line 8)

Kodo
04-29-2006, 05:38 AM
http://www.aspfaq.com/show.asp?id=2026

hassaan
04-29-2006, 01:32 PM
I used the new code as quoted on the above link

the new error that i get is:
error '8004020f' (line 20)

please help!!!
btw my hosting company said they used windows 2000 server

hassaan
05-06-2006, 04:20 AM
well.... all the errors that i was coming across have finally been resolved!

now i would like to ask one more thing...
is there a way i can send emails to anyone with a webpage in the email - like the newsletters that one gets often. i should just need to specify the URL in the script and it should show that URL to whosoever the mail was sent. i know how to send HTML in the mail that is with HTMLBody but what I would like to know is to how to send HTML pages in emails.
this way, i can send emails without having to change script everytime - i will just need to update the page which is being sent.
help!

Kodo
05-08-2006, 10:03 AM
yes,
make an html template and use the file system object to read the html text of that template to a stream and save it as a string. use that string as the body of the email.