ASP Email - how to

How do I send an email off of an asp form? I have a contact form that needs to be directly sent to a hardcoded email address. I am aware of the objnewmail method, but it isnt working and I would like another way to do this...
we have iis4, outlook express...etc on the nt server
Can someone supply a ready-to-go code?
LVL 2
jedimikeAsked:
Who is Participating?
 
PBallConnect With a Mentor Commented:
Claiming point i supposed :)
0
 
rajgnCommented:
You can use NewMail Object in the built in  library CDONTS(with IIS4.0) for mailing activities. It's very simple to use. You can build confirmation message based on the data the user enters(let's say 'mesg') then insert the following code to send it by mail.

Set objNewMail = CreateObject("CDONTS.NewMail")
objNewMail.Send("fromme@company.com", "toyou@company.com", "subject:Hello", _
                      mesg, 0) ' low importance
Set objNewMail = Nothing ' canNOT reuse it for another message

Use Bcc,Cc etc. properties of this object to send Bcc or Cc. For complete documentation of this object, refer to:

http://premium.microsoft.com/msdn/library/sdkdoc/iishelp/iis/htm/asp/amsmtp_0qzj.htm
0
 
rajgnCommented:
Assuming you didn't mean the above by 'objnewmail method'
0
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.

 
jedimikeAuthor Commented:
I got this example from you're other answer...It didnt work at all....code executes and no mail ever is sent...I used the EXACT same code as you wrote on the other guy's question....
Is there another way of doing this?
0
 
rajgnCommented:
Are you getting any errors? Can you post me the code you used in your case? Are you sure your're using IIS4.0(coz. IIS3.0 will not recognize this)? And check for the validity of the email ID's you used. I used the same in my case, never had any problems. Check for CDONTS in your server's registry. If that's also OK, you can think of third party controls. But I'm not sure how far they'll succeed(since component from Microsoft itself failed!). If you want to have info about other components, I can give you.
0
 
sybeCommented:
Function SendMail(strFrom, strSendTo, strCC, strSubject, strBody)
   Dim objMail
   IF strSendTo <> "" then
      Set objMail = CreateObject("CDONTS.Newmail")
      objMail.From    = strFrom
      objMail.To       = strSendTo
      objMail.cc      = strCC
      objMail.Subject = strSubject
      objMail.Body    = strBody
      objMail.Send
      Set objMail = Nothing
   
      SendMail = TRUE
   ELSE
      SendMail = FALSE
   END IF
End Function

0
 
rajgnCommented:
sybe:

How you'r comments are different from my solution (except including the same code in a seperate function)?
0
 
jedimikeAuthor Commented:
Here's my code.  This is the whole asp file with the exception of the code following the script

<%
'capture all of the data from the contact form
dim mailString
dim objNewMail

name=Request.QueryString("name")
address=Request.QueryString("address")
citystzip=Request.QueryString("citystzip")
phone=Request.QueryString("phone")
calltime=Request.QueryString("time")
email=Request.QueryString("email")
pname=Request.QueryString("pname")

paddress=Request.QueryString("paddress")
pcitystzip=Request.QueryString("pcitystzip")
pphone=Request.QueryString("pphone")
ptime=Request.QueryString("ptime")
pemail=Request.QueryString("pemail")

customer=Request.QueryString("customer")
vendor=Request.QueryString("vendor")
system=Request.QueryString("system")
upgrade=Request.QueryString("upgrade")

mailString = name & chr(10) & address & chr(10) & citystzip & chr(10)
mailString = mailString & phone & chr(10) & "The best time to call is :" & calltime & chr(10)
mailString = mailString & email & chr(10) & "My Pharmacy is : " & pname & chr(10)
mailString = mailString & paddress & chr(10) & pcitystzip & chr(10)
mailString = mailString & pphone & chr(10) & "The best time to call is :" & ptime & chr(10)
mailString = mailString & pemail & chr(10) & chr(10) & "Am I a current Mckesson Pharmacy Customer? " & customer & chr(10)
mailString = mailString & "My favorite software vendor is: "  & chr(10) & vendor & chr(10) & "How old is my system? " & system & chr(10)
mailString = mailString & "Do I plan on upgrading in the next 6 months?: " & chr(10) &  upgrade & chr(10)

'create the mail object
Set objNewMail = CreateObject("CDONTS.NewMail")  
objNewMail.from = "mmessagie@creabustech.com"
objNewMail.body = mailString
objNewMail.to = "mmessagie@creabustech.com"
objNewMail.subject ="Contact Information"
objNewMail.Send
Set objNewMail = Nothing 'canNOT reuse it for another message

'debugging statement
Response.Write "this was mailed"
%>
0
 
rajgnCommented:
I don't see any thing wrong with your code. Did you check the other possibilities I mentioned?
0
 
PBallCommented:
Make sure you have SMTP server installed when installing Option Pack 4.0.

And you need to configure the SMTP server to forward the email coming to it to the actual SMTP server (email gateway) for your company.  You can do so from Internet Service Manager.

If you don't have the correct setting (whether SMTP is not installed or no forwarding is set up) the code above will not function at all.  All you are going to have are a bunch of bad emails in the /mailroot/badmail directory of your web server (not sure where you put that thing also, but check there).


0
 
PBallCommented:
If you don't have the SMTP installed or don't know how to do it, another option is to use 3rd party email component such as JMail from Dimac (www.dimac.se).  It's free.

You still need to have a forwarding SMTP server to use to actually send the email across the net.  But with JMail and ASPMail, this option can be done programmatically.

something like:

objMail.SMTPserver = "163.111.20.10"

or something like that.

Again, you need to know your actual SMTP server address for it to work.
0
 
PBallCommented:
On IIS SMTP problem,
to set up the smart host (where to forward outgoing mail to),
launch ISM
Open SMTP property page
Tab over to delivery
and enter the IP address in the smart host field.

If you are using Exchange, you might try putting the IP address of the machine where the Exchange is into this field.

I think that's the only info that IIS SMTP need to work correctly.

You might want to check the mailroot/badmail directory also to see if the SMTP server are accepting your test emails that are sent thru CDO/NTS object.

Actually, check all directory under the mailroot directory (I dunno where you have that directory, go search on it, should be there).
0
 
jedimikeAuthor Commented:
well we dont have the default smtp server running. We have it stopped because when we have it running we it screws up the exchange server5.5...Is there any setting in either to get smtp server and exchange server to work together?

0
 
jedimikeAuthor Commented:
well we dont have the default smtp server running. We have it stopped because when we have it running we it screws up the exchange server5.5...Is there any setting in either to get smtp server and exchange server to work together?

0
 
jedimikeAuthor Commented:
well we dont have the default smtp server running. We have it stopped because when we have it running we it screws up the exchange server5.5...Is there any setting in either to get smtp server and exchange server to work together?

0
 
MasseyMCommented:
I could not get CDO to work.. I use a component called JMail from www.dimac.net.  It is great!  Try it out.  It is also free and VERY simple to use and install.
0
 
sybeCommented:
rajgn,

I posted the function as a comment, not because it is principally different from your solution, but because it is in a function, and I like to put things in functions.

I am sorry if that upset you.

0
 
jedimikeAuthor Commented:
already know about this...i need to know why cdo doesnt work....I cannot "rig" my code to function correctly. If the server is setup wrong I need to know why...
0
 
PBallCommented:
Heh, I am not sure if you have solved your problem by now, but something just pop into my head.  Perhaps, if you change the port number for the IIS SMTP server to something else (other than port 25 which is the default SMTP port), you can have both SMTP server running at the same time....

0
 
jedimikeAuthor Commented:
I figured out that Microsoft lied....Exchange and SMTP do NOT work together on the same machine. I moved all of my sites to a new machine and route the outgoing SMTP to the machine with exchange and it works fine...They just dont work on the same machine.
Pball,,,answer this and you get the points
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.