?
Solved

responding with Email in ASP

Posted on 2003-03-11
28
Medium Priority
?
273 Views
Last Modified: 2007-12-19
How does someone automatically send an email to a person using ASP.  Do you need 3rd party software or is it all in IIS.

More specifially, I have a database of users email address and would like to be able to email them to remind them their password.

Seems like a very common aplication for ASP however I have found nothing on it.

If there such thing as an SMTP objcet?
0
Comment
Question by:gdean
[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
  • 13
  • 9
  • 3
  • +2
28 Comments
 
LVL 4

Expert Comment

by:mberumen
ID: 8114129
There are multiple email components out there you might want to try ASPEmail at http:\\www.aspemail.com, alternatively you could use CDO

This is a sample use of ASPEMAIL

Set Mail = Server.CreateObject("Persits.MailSender")
     
     Mail.Host = "172.16.198.203" ' Specify a valid SMTP server
     Mail.From = "westregionoss@nextel.com "   ' Specify sender's address
     Mail.FromName = "NTM" ' Specify sender's name
     mail.addaddress ossemail
     Mail.Subject = ""HELLO"
     Mail.Body="email content goes here"
Mail.isHTML=false
     On Error Resume Next
     Mail.Send
     If Err <> 0 Then
     Response.Write "Error encountered: " & Err.Description
           End If
     
     
     set mail=nothing
0
 

Author Comment

by:gdean
ID: 8114163
So The operation requires thirda party software?
0
 

Author Comment

by:gdean
ID: 8114178
Are there any free applications available?
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 18

Expert Comment

by:mgfranz
ID: 8114261
Yes, CDO is installed with SMTP, (or is it installed with MDAC...)  I can't remember;

' Create the mailing object
Set objCDOAdmin = Server.CreateObject("CDO.Message")

     With objCDOAdmin
          .AutoGenerateTextBody = True ' Make a text message if needed
          .To       = rs_email 'toaddress
          .From     = "me@myself.com" ' From
          .Subject  = strSubject ' Subject
          .HtmlBody = strBody ' HTML Coded body
          .Send ' Finally send the message
     End With

' We don't want to halt if an error is encountered
On Error Resume Next
' We want to see what the error is!  ;-)
If Err <> 0 Then
     Response.Write "Error encountered: " & Err.Description
Else
     ' Response.Write "Message Sent"
End If

Response.Write FormatNumber(rs_ID, 0) & " messages sent."
' Finally, close the mail object
Set objCDOAdmin = Nothing
0
 
LVL 4

Expert Comment

by:mberumen
ID: 8114342
BTW as far as I know ASPEmail is free.. Or it used to be

0
 

Author Comment

by:gdean
ID: 8114405
I get this error mgfranz

CDO.Message.1 (0x80040220)
The "SendUsing" configuration value is invalid.
/LostPW.asp, line 10
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 8114430
Post your code.
0
 

Author Comment

by:gdean
ID: 8114489
    Set objCDOAdmin = Server.CreateObject("CDO.Message")
     with objCDOAdmin
          .AutoGenerateTextBody = True ' Make a text message if needed
          .To = "grdean@vt.edu" 'toaddress
          .From = "grdean@vt.edu" ' From
          .Subject = "strSubject" ' Subject
          .HtmlBody = "strBody" ' HTML Coded body
          .Send ' Finally send the message
     End With

     ' We don't want to halt if an error is encountered
     On Error Resume Next
     ' We want to see what the error is!  ;-)
     If Err <> 0 Then
          Response.Write "Error encountered: " & Err.Description
     Else
          Response.Write "Message Sent"
     End If

     Response.Write FormatNumber(rs_ID, 0) & " messages sent."
     ' Finally, close the mail object
     Set objCDOAdmin = Nothing
0
 

Author Comment

by:gdean
ID: 8114492
I need to tell it how to send the mail ie what server to use ....correct?  where do I do thtat?
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 8114510
Read my comments on the MSDN links... I'm guessing that you have Exchange running on the server, right?
0
 

Author Comment

by:gdean
ID: 8114528
no exchange is not running.  Can't it be doen without exchange?
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 8114563
Yes.  But the error you are getting is a direct error to the Exchange SP3 being installed.  You are running Winndows 2000 right?

Try this, it will work on NT;

Set objCDO = Server.CreateObject("CDONTS.NewMail")
objCDO.From = "xyz@internet.com"
objCDO.To = "abc@btinternet.com"
objCDO.cc = ""
objCDO.Subject = "Request for software"
objCDO.Body = mailFormat
objCDO.Send
Set objCDO = Nothing
0
 

Author Comment

by:gdean
ID: 8114602
Well I am running XP pro
0
 

Author Comment

by:gdean
ID: 8114639
Do i need to configure the SMTP server for IIS with the proper SMTP address?  Would that cause the error.  If so where / How do i do that
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 8114660
SMTP needs to be installed yes.
0
 

Author Comment

by:gdean
ID: 8114792
Its installed, Im just not sure hw it needs to be configured.  Also i think I noticed, in the links you posted,  something about having Outlook 2002 installed having the same effect that Exchange SP3.  But i think that article only applies to Windos 2k.  

I looked at the properties for SMTP Virtual host and I really dont know what i need.  It seems like I should have to specify an mail server somewhere for outgoing mail.  Do you have any insight to that?

With XP do i need the CDO or CDONTS?
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 8114819
CDO or CDONTS works with IIS5.1

There aren't any properties to set to make CDO work.
0
 

Author Comment

by:gdean
ID: 8114834
How does the CDo object know what mail server to use?
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 8114865
It will use SMTP from the server that the page is being called from.
0
 

Author Comment

by:gdean
ID: 8115192
I have followed mgfranz's coding suggestion however run into a problme because Outlook XP (Outlook 2002) is also installed on the machine.  The workarounds provided in the following link have led to no conclusions.

I am going to increase the points for this question and now ask for advice on how to solve this problem. please view the link for more details.

Here is the following code i used to try to correct the issue but to no prevail:

Const cdoSendUsingPort = 25
    Const strSmartHost = "smtp.blacksburg.ntc-com.net"
     Set objCDO = Server.CreateObject("CDO.message")
     objCDO.From = "blah"
     objCDO.To = "blah"
     objCDO.cc = ""
     objCDO.Subject = "Request for software"
    objCDO.Configuration.Fields.item("sendusing") = 1
    objCDO.Configuration.Fields.item("smtpserver") = strSmartHost
    objCDO.Configuration.Fields.item("smtpserverport") = cdoSendUsingPort
    objCDO.Configuration.Fields.Update

     objCDO.Send

http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B322338
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 8115325
I would say to try the SP3 update as detailed here? http://support.microsoft.com/default.aspx?scid=kb;EN-US;301378

But it's a 165mB download... quite unreasonable for a single .dll.  I wonder if you can .CAB the dll Cdoex.dll 6.0.5770.96 from a disk of from somewhere on the web.

Here is something I found that has some interest...
"If Office XP or Sharepoint Portal or Team Server or Exchange 2000 is installed on machine then CDOEX.DLL is registered instead of cdosys.dll, otherwise CDOSYS.DLL registered.  Registering one un-registers the other one."

Try unregistering the cdoex.dll and then see if the cdosys.dll registered, try the different samples then.

0
 
LVL 3

Expert Comment

by:engineroom
ID: 8116111
why don't you try a simple script to see if your cdonts works.

<%

set cdoObj = server.createObject("cdonts.newMail")
cdoObj.To = "anemailyouhave@hotmail.com" ' use an outside source to see if you get the message.
cdoObj.from = "mySelf" 'there must be no spaces the from field
cdoObj.subject = "This is your subject"
cdoObj.body = "this is your body"
cdoObj.send

set cdoObj = nothing

%>

run this script through your server. if this works then we know cdo works..  

http://localhost/cdoTest.asp

try that and if it works, well do the rest. Emailing to everyone in your database.

:)
0
 

Author Comment

by:gdean
ID: 8116163
The CDONTS will not work.  "Invalid class string".  In fact I believe that they dont work with XP...not sure but i thought I read that somewhere.

As far as the SP3 goes I dont understand why they recommend that as the article specifies that the user doesn't have exchange installed.  
0
 
LVL 3

Expert Comment

by:DRY_GIN
ID: 8116259
same question has been raised and answer has been accepted here:
http://www.experts-exchange.com/Operating_Systems/WinXP/Q_20440413.html
0
 
LVL 3

Accepted Solution

by:
DRY_GIN earned 600 total points
ID: 8116280
addition:
here is a direct link to CDONTS.dll :

http://crt.doce.lsu.edu/CRT-HTML-Class/Lesson29a.html
0
 

Author Comment

by:gdean
ID: 8116295
I am assuming that you are suggesting that i regiter CDONTS.dll and just use CDONTS....?
0
 
LVL 3

Expert Comment

by:DRY_GIN
ID: 8117574
Hello, thanks for acception of my answer,
Here is nice function for all you e-mail needs
Note: if you have too many emails to send - it is better to split emails on groups by let's say 25 e-mails with up to 20 recepients in each (I'm not sure about actual limitations)
and to keep self-refreshing your asp file with ID of last sended mail as a parameter. You can even design "nice progress bar" so it will look like a real mass-mailer ;)

If you want users to do not see each other:

In TO field put something like "My Web Site Customers"
In CC field - do not put anything
In BCC field put list of emails splitted by ";"
It is important that "From" email should exist (registered)
you can use "Replay-To" email for answers and it could be different from "From" e-mail.


function SendMail(sTo, sFrom,sCC,sBCC, sPriority, sSubject, sBody, bHTML,replemail)
 on error resume next
    Const cdoLow = 0
    Const cdoNormal = 1
    Const cdoHigh = 2
    Const CdoBodyFormatText = 1
    Const CdoMailFormatText = 1
    Set oMailMessage = server.CreateObject("CDONTS.NewMail")
    oMailMessage.To = sTo
    oMailMessage.Bcc = sBCC    
    oMailMessage.Cc = sCC
    oMailMessage.To = sTo
    oMailMessage.Value("Reply-To") = replemail  
    oMailMessage.From = sFrom
    sPriority = ucase(sPriority)
    if sPriority = "LOW" then
        oMailMessage.importance = cdoLow
    elseif sPriority = "HIGH" then
        oMailMessage.importance = cdoHigh
    else
        oMailMessage.importance = cdoNormal
    end if    
    if bHTML then 'this is mail format (plain text or html)
        oMailMessage.BodyFormat = CdoBodyFormatText
        oMailMessage.MailFormat = CdoMailFormatText
    end if
    oMailMessage.Body = replace(sBody,"|",chr(13) & chr(10))
     oMailMessage.Subject = sSubject
    oMailMessage.Send
    set oMailMessage = nothing
    if Err then
        SendMail = false
        err.clear
    else
        SendMail = true
    end if
On error goto 0
end function

comment: I'm using "|" as line separator in e-mail body instead of Chr(13) & chr(10) to make everything easy to use

Good luck
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

777 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