'ASP'에 해당되는 글 5건
- 2013.09.10 ASP에서 메일 보내기 2
mailFrom = send_user
mailTo = receive_user
mailSubject = subject
mailHTMLBody = message_contents
If InStr(mailTo, "@") > 0 Then
Const cdoSendUsingMethod = "http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort = 2 ' 1 로컬 SMTP, 2 외부 SMTP
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/smtpconnectiontimeout"
Const cdoSMTPAccountName = "http://schemas.microsoft.com/cdo/configuration/smtpaccountname"
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
With Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "smtp.*******.******"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = "*************"
.Item(cdoSendPassword) = "*************"
.Update
End With
Set objMessage = Server.CreateObject("CDO.Message")
Set objMessage.Configuration = objConfig
With objMessage
.BodyPart.Charset = "ks_c_5601-1987" ' 한글이 깨지면 이렇게 설정
.To = mailTo
.From = mailFrom
.Subject = mailSubject
.HTMLBody = mailHTMLBody
.HTMLBodyPart.Charset = "ks_c_5601-1987" ' 본문 한글이 깨지면 캐릭터셋 설정
.AddAttachment "" & UploadDirectory & ""& FileName & "" ' 파일 업로드한 서버 경로를 사용
.fields.update
.Send
End With
Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing
End If