Language/ASP | Posted by 아키텍처 2012. 4. 24. 15:31

WindowServer에서 ASP로 메일 보내기 함수 2

 
 

▣ WindowServer에서 ASP로 메일 보내기 함수 2

 

* 2003버젼부터 Cdonts를 지원하지 않으므로 Cdo for win 2000 으로 변경(2000, 2003둘다지원됨.)

 

' sub_SendMail(보내는이름, 보내는주소, 받는주소, BodyFormat, MailFormat, 제목, 내용)
Sub sub_SendMail(fromName, fromAddr, email, BodyFormat, MailFormat, title, content)

 ' 테스트 모드일때는 발송되지 안게함. 고객에게 메일이 발송되는것을 막기위함
 If m_ServerMode = "test" Then
  Exit Sub
 End If

 Dim objMail, objConfig, Flds

 Set objMail = Server.CreateObject("CDO.Message")

 ' SMTP Configuration
 set objConfig = createobject("CDO.Configuration")
 Set Flds = objConfig.Fields

 With Flds
  .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
  .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost" 
  .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10 
  .Update
 End With

 With objMail
  Set.Configuration = objConfig
  .From= fromName &"<"& fromAddr &">"
  .To= email
  .Subject= title
  IF MailFormat = 0 Then ' Html형식일때
   .HTMLBody = content
  Else   'Text 형식일때
   .TextBody = content
  End IF
  '.BodyPart.Charset = "euc-kr"
  .BodyPart.Charset = "ks_c_5601-1987"         '/// 한글을 위해선 꼭 넣어 주어야 합니다.
  .HTMLBodyPart.Charset = "ks_c_5601-1987" '/// 한글을 위해선 꼭 넣어 주어야 합니다.
  .Send
 end with 

 Set Flds = Nothing
 Set objConfig = Nothing
 Set objMail = Nothing

End Sub

Posted by 김준홍 (http://www.Juuun.com)