p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Professional (http://p2p.wrox.com/forumdisplay.php?f=63)
-   -   e-mail a webpage (http://p2p.wrox.com/showthread.php?t=44960)

rylemer July 7th, 2006 04:56 PM

e-mail a webpage
 
Hi! Everyone

I used vbsendmail as a component to send e-mail and it works fine.
I try to use send a whole webpage thru emai using ASP.
I need your help any idea to do it.

Thanks,
Elmer


cstooch July 7th, 2006 11:23 PM

This command goes at the top of your page:
Code:


Here is the function you use for sending the mail:
Code:

<%'VBScript function to send email using CDOSYS
' Usage: sendEmail "to@somewhere.com", "from@somewhere.com", "Subject", "Body"
Function sendEmail(address_to, address_from, subject, body)
     'the mail object
     Dim ObjMail
     Set ObjMail = CreateObject("CDO.Message")
     'mail configuration
     Dim objConfig
     Set objConfig = CreateObject("CDO.Configuration")
 
     'replace any line breaks in the mail body with <br> tag for HTML email
     emailBody = Replace(body, chr(10), "<br>")
 
     'set up the mail server, port etc.
     With objConfig
          .Fields(cdoSendUsingMethod) = cdoSendUsingPort
          'Try Local Machine
          .Fields(cdoSMTPServer) = "someservernamehere" 'change the server name, of course
          .Fields(cdoSMTPServerPort) = 25
          .Fields(cdoSMTPAuthenticate) = cdoBasic
          .Fields.Update
     End With
 
     'the message
     With objMail
          .Configuration = objConfig
          .From = address_from
          .To = address_to
          .Subject = subject
          .HTMLBody = emailBody 'for sending HTML email
                                '.TextBody = emailBody  'for sending Text only email
          .Send
     End With
 
     Set objMail = Nothing
     Set objConfig = Nothing
 
End Function
%>

Then just call this function like so:

sendEmail EmailToSendTo, EmailToSendFrom, Subject, BodyOfTheEmail




rylemer July 10th, 2006 04:20 PM

cstooch,

Thanks for your reply. CDOSYS
is a free components to send an email. if so where can I download it?

Elmer


cstooch July 10th, 2006 11:18 PM

I thought CDOSYS was built in to ASP...

I had to include this line at the top of my pages for it to work though:




rylemer July 11th, 2006 11:26 AM

cstooch,

Wow thanks for your help it works..

Thanks,
Elmer


cstooch July 11th, 2006 08:05 PM

Awesome, glad I could help!



All times are GMT -4. The time now is 01:23 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.