나누미넷 도움말 센터

Home > CDO 메일 발송 예제 소스

CDO 메일 발송 예제 소스

<%
Server.ScriptTimeout = 6000
dim xattach, xup, filename(3), count

set xup = Server.CreateObject("UpDownExpress.FileUpload")
xup.Open
mailto = xup("mail_to")
mailfrom = xup("mail_from")
mailsubject = xup("mail_subject")
mailbody = xup("mail_body")
if XUP.Attachments.Count > 0 then
count = 1
For each xattach in xup.Attachments
filepath = server.mappath(".") & "\UpFiles\"
xattach.SaveFile filepath & xattach.FileName,False
filename(count) = filepath & xattach.FileName
count = count + 1
Next
End If
count = count - 1
xup.Close
set xup = nothing

mailbody = RePlace(mailbody,"&","&")
mailbody = RePlace(mailbody,"<","<")
mailbody = RePlace(mailbody,">",">")
mailbody = RePlace(mailbody,chr(13)&chr(10),"<br>")

Dim myMail
set myMail = server.createobject("CDONTS.NewMail")

' If count <> 0 Then
For i = 1 To count
myMail.Attachfile filename(i),,1
Next
' End If

myMail.from = mailfrom
myMail.to = mailto
myMail.subject = mailsubject
myMail.BodyFormat = 0
myMail.MailFormat = 0
myMail.body = mailbody
myMail.send
set myMail = nothing


If count <> 0 Then

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

For i = 1 To count
fso.deletefile(filename(i))
Next

End If

Response.Redirect "cmail_write.asp"
%>