2003/04/18

Remote SMTP CDONTS를 이용하여 메일발송

다음 Asp 코드는 Remote SMTP Server를 이용해서 메일을 발송하는 예제 코드입니다.

'Send by connecting to port 25 of the SMTP server.
Dim iMsg
Dim iConf
Dim Flds
Dim strHTML

Const cdoSendUsingPort = 2

set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")

Set Flds = iConf.Fields

'Set the CDOSYS configuration fields to use port 25 on the SMTP server.

With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
ToDo: Enter name or IP address of remote SMTP server.
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "remote server"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update
End With

'Build HTML for message body.
strHTML = ""
strHTML = strHTML & ""
strHTML = strHTML & ""
strHTML = strHTML & " This is the test HTML message body
"
strHTML = strHTML & ""
strHTML = strHTML & ""

'Apply the settings to the message.
With iMsg
Set .Configuration = iConf
.To = "mailfrom@serverinfo.pe.kr" 'ToDo: Enter a valid email address.
.From = "mailto@serverinfo.pe.kr" 'ToDo: Enter a valid email address.
.Subject = "This is a test CDOSYS message (Sent via Port 25)"
.HTMLBody = strHTML
.Send
End With

'Clean up variables.
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing

MsgBox "Mail Sent!"


참고 : MSDN

댓글 없음:

댓글 쓰기

가장 많이 본 글