Computer/ASP

CDO 객체를 이용한 메일발송 ASP 예제 (SMTP 인증)

알찬돌삐 2011. 11. 29. 09:32
CDO.Message 와 CDONTS.NewMail 의 차이점은
cdonts 는 NT 에 제공된 메일 컴포넌트 이며 2000서버부터 CDO가 제공되었습니다. 
물론 2000에서는 호환성 때문인지는 모르지만 cdonts도 같이 제공되었구요. 
XP Pro / 2003 서버에서는 더이상 cdonts는 제공되지 않습니다. 

일반적인 CDO 메일발송과 다른점은 SMTP 인증에 관한 부분이 추가되어 있는 점입니다. 
참고로 CDONTS 객체는 원격접속과 SMTP 인증기능이 없으므로 위와 같이 CDO 로 구현하셔야 합니다.
  1. Const cdoSendUsingMethod = _
  2. "http://schemas.microsoft.com/cdo/configuration/sendusing"
  3. Const cdoSendUsingPort = 2
  4. Const cdoSMTPServer = _
  5. "http://schemas.microsoft.com/cdo/configuration/smtpserver"
  6. Const cdoSMTPServerPort = _
  7. "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
  8. Const cdoSMTPConnectionTimeout = _
  9. "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
  10. Const cdoSMTPAccountName = _
  11. "http://schemas.microsoft.com/cdo/configuration/smtpaccountname"
  12. Const cdoSMTPAuthenticate = _
  13. "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
  14. Const cdoBasic = 1
  15. Const cdoSendUserName = _
  16. "http://schemas.microsoft.com/cdo/configuration/sendusername"
  17. Const cdoSendPassword = _
  18. "http://schemas.microsoft.com/cdo/configuration/sendpassword"
  19.  
  20. Dim objConfig ' As CDO.Configuration
  21. Dim objMessage ' As CDO.Message
  22. Dim Fields ' As ADODB.Fields
  23.  
  24. ' Get a handle on the config object and it's fields
  25. Set objConfig = Server.CreateObject("CDO.Configuration")
  26. Set Fields = objConfig.Fields
  27.  
  28. ' Set config fields we care about
  29. With Fields
  30. .Item(cdoSendUsingMethod) = cdoSendUsingPort
  31. .Item(cdoSMTPServer) = "메일서버주소"
  32. .Item(cdoSMTPServerPort) = 25
  33. .Item(cdoSMTPAuthenticate) = cdoBasic
  34. .Item(cdoSendUserName) = "POP메일아이디@POP메일도메인"
  35. .Item(cdoSendPassword) = "POP메일비밀번호"
  36.  
  37. .Update
  38. End With
  39.  
  40. Set objMessage = Server.CreateObject("CDO.Message")
  41.  
  42. Set objMessage.Configuration = objConfig
  43.  
  44. With objMessage
  45. .To = "batman@gotham.com"
  46. .From = "superman@crypton.net"
  47. .Subject = "Hello, this is test mail"
  48. .HTMLBody = "Hello"
  49. .Send
  50. End With
  51.  
  52. Response.Write "Success"
  53.  
  54. Set Fields = Nothing
  55. Set objMessage = Nothing
  56. Set objConfig = Nothing

.

'Computer > ASP' 카테고리의 다른 글

펌) dext업로드 컴포넌트에 대해서..  (0) 2011.11.29
펌) asp에서 디비작업 최적화하기  (0) 2011.11.29
ASP CDONTS 메일 발송  (0) 2011.11.29
CDO 객체를 이용한 메일발송 ASP 예제  (0) 2011.11.29
asp 용 substring.  (0) 2008.01.11