?
Solved

ASP Email - how to

Posted on 1998-12-15
20
Medium Priority
?
201 Views
Last Modified: 2013-12-25
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?
0
Comment
Question by:jedimike
[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
  • 7
  • 5
  • 5
  • +2
20 Comments
 
LVL 1

Expert Comment

by:rajgn
ID: 1857245
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
 
LVL 1

Expert Comment

by:rajgn
ID: 1857246
Assuming you didn't mean the above by 'objnewmail method'
0
 
LVL 2

Author Comment

by:jedimike
ID: 1857247
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Expert Comment

by:rajgn
ID: 1857248
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
 
LVL 28

Expert Comment

by:sybe
ID: 1857249
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
 
LVL 1

Expert Comment

by:rajgn
ID: 1857250
sybe:

How you'r comments are different from my solution (except including the same code in a seperate function)?
0
 
LVL 2

Author Comment

by:jedimike
ID: 1857251
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
 
LVL 1

Expert Comment

by:rajgn
ID: 1857252
I don't see any thing wrong with your code. Did you check the other possibilities I mentioned?
0
 
LVL 6

Expert Comment

by:PBall
ID: 1857253
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
 
LVL 6

Expert Comment

by:PBall
ID: 1857254
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
 
LVL 6

Expert Comment

by:PBall
ID: 1857255
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
 
LVL 2

Author Comment

by:jedimike
ID: 1857256
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
 
LVL 2

Author Comment

by:jedimike
ID: 1857257
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
 
LVL 2

Author Comment

by:jedimike
ID: 1857258
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
 
LVL 10

Expert Comment

by:MasseyM
ID: 1857259
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
 
LVL 28

Expert Comment

by:sybe
ID: 1857260
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
 
LVL 2

Author Comment

by:jedimike
ID: 1857261
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
 
LVL 6

Expert Comment

by:PBall
ID: 1857262
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
 
LVL 2

Author Comment

by:jedimike
ID: 1857263
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
 
LVL 6

Accepted Solution

by:
PBall earned 300 total points
ID: 1857264
Claiming point i supposed :)
0

Featured Post

AWS Certified Solutions Architect - Associate

This course has been developed to provide you with the requisite knowledge to not only pass the AWS CSA certification exam but also gain the hands-on experience required to become a qualified AWS Solutions architect working in a real-world environment.

Question has a verified solution.

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

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

800 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