Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How can I send email with ASP?

Posted on 2001-06-08
5
Medium Priority
?
326 Views
Last Modified: 2012-08-13
How can I send email with ASP?
The code listed below gives me an error like this:

Error Type:
Server object, ASP 0177 (0x800401F3)
Invalid ProgID. For additional information specific to this message please visit the Microsoft Online Support site located at: http://www.microsoft.com/contentredirect.asp.

I have installed a Virtual SMTP server on my IIS server, I have access to a real linux SMTP server, which is not on my server machine, please help me guys?!
<%
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = "smtp.smtp-server.com" ' Specify a valid SMTP server
Mail.From = "sales@veryhotcakes.com" ' Specify sender's address
Mail.FromName = "VeryHotCakes Sales" ' Specify sender's name

Mail.AddAddress "andy@andrewscompany.net", "Andrew Johnson, Jr."
Mail.AddAddress "paul@paulscompany.com" ' Name is optional
Mail.AddReplyTo "info@veryhotcakes.com"
Mail.AddAttachment "c:\images\cakes.gif"

Mail.Subject = "Thanks for ordering our hot cakes!"
Mail.Body = "Dear Sir:" & Chr(13) & Chr(10) & _
    "Thank you for your business."

On Error Resume Next
Mail.Send
If Err <> 0 Then
  Response.Write "Error encountered: " & Err.Description
End If
%>
0
Comment
Question by:lentzi
[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
5 Comments
 
LVL 15

Expert Comment

by:liebrand
ID: 6167995

Its pretty straight forward... do the following:

<%

set oMail = server.createobject("CDONTS.NewMail")

oMail.from = "from@email.com"
oMail.to = "to@email.com"
oMail.subject = "The subject line"
oMail.Body = "The body of the email"
oMail.Send

%>

0
 
LVL 5

Expert Comment

by:dredge
ID: 6168006
liebrands's solution required that you have an SMTP server setup inside of IIS - this is not a band thing, it's just one alternative.

i prefer to use JMail from Dimac. http://tech.dimac.net - it's a free email component that i find easier to use than CDONTS, and more powerful as well.

that's just my opinion. alot of people use CDO and CDONTS - it works great. i just prefer JMail.
0
 
LVL 20

Accepted Solution

by:
Michel Sakr earned 400 total points
ID: 6168140
Comment out the on error resume next to see the error, basically I guess you should give the iusr read permission over the gif file.. check

http://support.microsoft.com/support/kb/articles/Q228/4/65.asp 
 

FYOI:

How do I send e-mail from ASP?

There are several components that enable you to do this. You may already have one, if you have an SMTP server installed alongside IIS - it's called CDONTS. Here is the documentation and an article for CDONTS:
 
    http://msdn.microsoft.com/library/psdk/cdo/_denali_newmail_object_cdonts_library_.htm 
    http://www.aspfaq.com/faq/faqShow.asp?fid=49 
 
There are also several other components available (if I missed any, let us know)
 
    Genusa's AspMail
    http://www.serverobjects.com/products.htm#Aspmail 
 
    ASPEmail
    http://www.aspemail.com/ 
 
    Dundas Mailer
    http://www.dundas.com/index.asp?/products/mailer 
 
    MailListBot
    http://www.MailListBot.com/ 
 
    EasyMail
    http://www.easymailobjects.com/emobjects/smtp.asp 
 
    w3 Jmail
    http://www.dimac.net/ 
 
    HTMLMailer / HTMLMailerPlus
    http://www.oopadelic.com/htmlmailer/ 
    http://www.oopadelic.com/htmlmailerplus/ 
 
    DevMailer
    http://www.geocel.com/devmailer/ 
 
    VSEmail
    http://www.vsoft-tech.com.au/vsemail/readme.html 
 
    Mabry Mail
    http://www.mabry.com/mail/index.htm 
 
    NNTPClient+SMTPClient
    http://www.liquidcool.com/asp 
 
    SimpleMail
    http://www.adiscon.com/SimpleMail 
 
    AB Active X Mailer
    http://www.geocities.com/ResearchTriangle/2656/abmailer.html 
 
    OCXMail
    http://www.flicks.com/aspmail/ 
 
    WindMail
    http://www.geocel.com/windmail/ 
 
    Zaks.POP3
    http://www.zaks.demon.co.uk/code/cpts/pop/index.html 


How do I send e-mail with CDONTS?

To send an e-mail with Active Server Pages requires some kind of component. There are many third party components available (see bottom of page), but one of the most readily available is the free Microsoft mail component CDONTS, which ships with the Option Pack for WinNT 4.0.
 
Now, once you stop trying to comprehend it's name (I know I can't), it is quite a simple mail program to use once you set it up.
 
CDO works by using the SMTP service in IIS, unless Exchange is installed, then it will just use Exchange's SMTP system. Before continuing, make sure you have your SMTP service properly set up. You can check by using the Microsoft Management Consol (MMC), or you can look to see if CDONTS.DLL is in your system32 directory.
 
To send e-mail from ASP, all you have to do is define the object and use the ".send" function.
 
<%
    Set MailObj = Server.CreateObject("CDONTS.NewMail")
    MailObj.Send "from@me.com", "to@me.com", "My Subject", "My Text"
%>
 
 
Wasn't that easy?
 
---------------------
Sending an Attachment
---------------------
 
Another very commonly used function of CDO is to send attachments with an e-mail.
 
<%
    Set MailObject = Server.CreateObject("CDONTS.NewMail")
    att_file="c:attachmentsStandardPolicy.txt"
    f_name="Policy.txt"
    MailObject.From="from@me.com"
    MailObject.To="to@me.com"
    MailObject.Subject="Subject Text Here"
    MailObject.Body="Body Text Here"
    MailObject.AttachFile att_file,f_name
    MailObject.Send
%>
 
 
Along with CDO, there are many third party components that can also be used for sending e-mail. Many of them have more features than CDO. You might want to have a look at:
 
    http://www.aspfaq.com/faq/faqShow.asp?fid=29 
 
If you get "Permission Denied" errors, see the following KB article:
 
    http://support.microsoft.com/support/kb/articles/Q228/4/65.asp 
 

0
 
LVL 18

Expert Comment

by:mgfranz
ID: 6169410
If you are running IIS5 on W2K you don't even need an SMTP server, just the SMTP Service...
0
 

Expert Comment

by:melio
ID: 6176109
hi lentzi,

i just want to make sure... have you registered the persits mail component or dll on your web server? this is achieved by running windows' regsvr32 and passing to it as a parameter the absolute pathname of the dll. if yes, try rebooting your server if you also haven't done this.

anyway, your invalid progid error just says that our asp engine could not find the persits.mailsender programmatic id in the registry.
0

Featured Post

Independent Software Vendors: 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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
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…

609 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