![]() |
|
|
+ Search |
![]()
|
Mar 22nd, 2004 23:41
Jason Benson, jabir shah, http://msdn.microsoft.com/library/default.asp?url=/library/en-us/exchanchor/htms/msexchsvr_cdowin2000.asp
The CDOSys Object provided in 2000 and up is just the object for this task. CDOSys replaces CDONTs and provides a level of security not present in CDONTs ASP/VB Code Example of CDOSys follows this answer. Notice the first 7 variables in the code (SMTPServer,SMTPUser etc). Those need to be set in order for the CDOSys to correctly connect to your SMTP (outgoing) mail server. Specifiying the "PageVar" variable (7th variable) will tell the script to build and send and HTML encoded email (with your page as the contents.) Extremely usefull. See: .CreateMHTMLBody PageVar, cdoSuppressAll The CreateMHTMLBody method is just one of the many methods CDOSys provides for handling email types. Check out this URL for more information on CDOSys and the many ways it can help you simply your email structure on your site. (If I sound like a fan I am. It's a great improvement over the old CDONTs system.) http://msdn.microsoft.com/library/default.asp?url=/library/en- us/exchanchor/htms/msexchsvr_cdowin2000.asp I hope that helps, jb CDOSys Example: (For use in Windows 2000+) <% '''CDOSys Example''' 'Please Note Storing Passwords and Usernames in code form is a bad idea. Example for, well, example purposes only ;). 'Declare the fields that we need to set data in. Dim SMTPServer,SMTPUser,SMTPPass,FromVar,CCVar,ToVar,PageVar SMTPServer = "mail.replacewithyourmaildomain.com" SMTPUser = "MyUserName" 'Do not save usernames & passwords in your code! SMTPPass = "MyPassword" 'Do not save usernames & passwords in your code! ToVar = "tosomeuser@replacewitha.domain.com" FromVar = "fromsomeuser@replacewitha.domain.com" CCVar = "ccsomeuser@replacewitha.domain.com" PageVar = "http://www.replacwitharealdomainandpage.com/index.html" Const cdoSendUsingMethod = _ "http://schemas.microsoft.com/cdo/configuration/sendusing" Const cdoSendUsingPort = 2 Const cdoSMTPServer = _ "http://schemas.microsoft.com/cdo/configuration/smtpserver" Const cdoSMTPServerPort = _ "http://schemas.microsoft.com/cdo/configuration/smtpserverport" Const cdoSMTPConnectionTimeout = _ "http://schemas.microsoft.com/cdo/configuration/smtpconnectionti meout" Const cdoSMTPAuthenticate = _ "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate " Const cdoBasic = 1 Const cdoSendUserName = _ "http://schemas.microsoft.com/cdo/configuration/sendusername" Const cdoSendPassword = _ "http://schemas.microsoft.com/cdo/configuration/sendpassword" Dim objConfig ' As CDO.Configuration Dim objMessage ' As CDO.Message Dim Fields ' As ADODB.Fields ' Get a handle on the config object and it's fields Set objConfig = Server.CreateObject("CDO.Configuration") Set Fields = objConfig.Fields ' Set config fields we care about (using variables from above) With Fields .Item(cdoSendUsingMethod) = cdoSendUsingPort .Item(cdoSMTPServer) = SMTPServer .Item(cdoSMTPServerPort) = 25 .Item(cdoSMTPConnectionTimeout) = 10 .Item(cdoSMTPAuthenticate) = cdoBasic .Item(cdoSendUserName) = SMTPUser .Item(cdoSendPassword) = SMTPPass .Update End With Set objMessage = Server.CreateObject("CDO.Message") Set objMessage.Configuration = objConfig 'build our message (again variables from above) With objMessage .To = ToVar .From = FromVar .BCC = CCVar .Subject = SubVar .CreateMHTMLBody PageVar, cdoSuppressAll .Send End With 'close our objects and tidy up Set Fields = Nothing Set objMessage = Nothing Set objConfig = Nothing %>
© 1999-2004 Synop Pty Ltd