ClassicASP 신청서 저장, SMS, 메일보내기 샘플
페이지 정보
본문
### 방법1 ###
<%
Option Explicit
set dbcon = Server.CreateObject("ADODB.Connection")
dbcon.Open "Provider=SQLOLEDB.1; Password=비밀번호; Persist Security Info=True; User ID=아이디; Initial Catalog=디비이름; Data Source=디비주소"
name = request("name")
birth = request("birth")
birth4 = request("birth4")
zip = request("zip")
address = request("address")
email = request("email")
tel = request("tel")
hp = request("hp")
job1 = request("job1")
job2 = request("job2")
job3 = request("job3")
religion = request("religion")
hope1 = request("hope1")
hope2 = request("hope2")
hope3 = request("hope3")
moneyhow = request("moneyhow")
money = request("money")
bank = request("bank")
content = request("content")
dim now_year, now_month, now_day, now_hour, now_minute, now_second, now_micro
now_year = left(now(),4)
now_month = mid(now(),6,2)
now_day = mid(now(),9,2)
now_hour = right("0" & hour(now), 2)
now_minute = right("0" & minute(now), 2)
now_second = right("0" & second(now), 2)
now_micro = right("000" & (timer * 1000) Mod 1000, 3)
'dd = now_year &"-"& now_month &"-"& now_day &" "& now_hour &":"& now_minute &":"& now_second &"."& now_micro ' ex: 2016-08-30 04:37:05.855
dd = now() ' 년-월-일 시:분:초 , 필드 데이타형식 varchar - 길이 24 ex: 2016-08-30 오전 4:38:43
'dd= date() ' 년-월-일 , 필드 10자 , 필드 데이타형식 datetime ex: 2016-08-30
'Response.Write("getdate=" & dd & "<br>")
' SMS 시작 (다이렉트 호스팅일때)
' stran_phone = "010-1234-5678" '수신자 전화번호
' 여러번호일 경우에는 ;으로 구분, 전화번호 구분자 대쉬(-)는 있거나 없거나 상관없음
' stran_callback = request("hph1")&"-"&request("hph2")&"-"&request("hph3") ' 송신자 전화번호
'stran_date = request("예약전송") ' 예약전송시에만 (예.2003-01-01 13:01)
stran_msg = "청호 , " & request("name") & "," & request("ss") & "," & request("gname") & " 온라인 예약이 접수 되었습니다."
' 전송메시지, 한글은 40자, 영문80자
guest_no = "서비스번호" ' 서비스번호
guest_key = "인증번호" ' SMS인증키
' result = request("반환값") ' 반환값 [ 성공시(OK), 실패시(에러메시지) ], 생략가능
' Response.Write("hp=" & hp & "<br>")
' Response.Write("stran_callback=" & stran_callback & "<br>")
' Response.Write("stran_msg=" & stran_msg & "<br>")
' Response.Write("guest_no=" & guest_no & "<br>")
' Response.Write("guest_key=" & guest_key & "<br>")
' 여기부터는 수정사항 없음
if trim(stran_phone) <> "" then
Set xmldoc = CreateObject("MSXML2.DOMDocument.4.0")
xmldoc.async = false
xmldoc.setProperty("ServerHTTPRequest")=True
texts = "http://sms.direct.co.kr/link/send.php?" & _
"stran_phone=" & stran_phone & "&stran_callback=" & stran_callback & _
"&stran_date=" & stran_date & "&stran_msg=" & server.URLEncode(stran_msg) & _
"&guest_no=" & guest_no & "&guest_key=" & guest_key
xmldoc.load texts
result = xmldoc.text
set xmldoc = nothing
end if
' SMS 끝
'====== 입력하기 ===========================================
SQL = "INSERT INTO application "
SQL = SQL & " (name, email, content, wdate) VALUES "
SQL = SQL & " ( '"& name &"' "
SQL = SQL & ", '"& email &"' "
SQL = SQL & ", '"& content &"' "
SQL = SQL & ", '"& dd &"' "
SQL = SQL & ")"
dbcon.Execute sql
strBody = strBody & "<table width=500 border=0 cellpadding=0 cellspacing=0><tr>"
strBody = strBody & "<td width=110 height=2 bgcolor=#4E78C2></td><td bgcolor=#4E78C2></td>"
strBody = strBody & "</tr><tr>"
strBody = strBody & "<td width=110 height=30 align=center bgcolor='#f7f7f7' style='font-size:12px;'>성<font color='#f7f7f7'>..</font>명</td>"
strBody = strBody & "<td style='padding:0 10 0 10;font-size:12px;'>"&name&"</td>"
strBody = strBody & "</tr><tr><td width=110 height=1 bgcolor='#dadada'></td><td bgcolor='#dadada'></td>"
strBody = strBody & "</tr><tr>"
strBody = strBody & "<td height=30 align=center bgcolor='#f7f7f7' style='font-size:12px;'>휴 대 폰</td>"
strBody = strBody & "<td style='padding:0 10 0 10;font-size:12px;'>"&hp&"</td>"
strBody = strBody & "</tr><tr>"
strBody = strBody & "<td width=110 height=1 bgcolor='#dadada'></td><td bgcolor='#dadada'></td>"
strBody = strBody & "</tr></table>"
Set objMail = Server.CreateObject("CDO.Message")
objMail.BodyPart.Charset = "euc-kr"
objMail.HTMLBodyPart.Charset = "euc-kr"
objMail.From = "보내는메일@happyjung.com"
objMail.To = "받는메일@happyjung.com"
objMail.Subject ="메일제목"
objMail.HTMLBody = strBody
' objMail.TextBody = strBody
objMail.send
set objMail = nothing
Response.Redirect "application_thanks.asp"
%>
### 방법2 ###
ASP 에서 메일발송하는 방법
폼메일 만들때 사용하는 소스 ^^
<%
Set objMail = Server.CreateObject("CDONTS.NewMail")
objMail.BodyPart.Charset = "euc-kr"
objMail.HTMLBodyPart.Charset = "euc-kr"
objMail.From = "보내는메일@happyjung.com"
objMail.To = "받는메일@happyjung.com"
objMail.Subject = "메일제목"
objMail.BodyFormat = 0 '0:HTML,1:TEXT
objMail.MailFormat = 0 '0:MIME,1:TEXT
objMail.Body = "내용"
objMail.importance=0 ' 메일 우선순위 0:가장빠름, 1:보통, 2:느림.
objMail.Send
Set objMail = Nothing
%>
참고자료
http://www.namul.pe.kr/entry/ASP-메일발송하기
<%
Option Explicit
set dbcon = Server.CreateObject("ADODB.Connection")
dbcon.Open "Provider=SQLOLEDB.1; Password=비밀번호; Persist Security Info=True; User ID=아이디; Initial Catalog=디비이름; Data Source=디비주소"
name = request("name")
birth = request("birth")
birth4 = request("birth4")
zip = request("zip")
address = request("address")
email = request("email")
tel = request("tel")
hp = request("hp")
job1 = request("job1")
job2 = request("job2")
job3 = request("job3")
religion = request("religion")
hope1 = request("hope1")
hope2 = request("hope2")
hope3 = request("hope3")
moneyhow = request("moneyhow")
money = request("money")
bank = request("bank")
content = request("content")
dim now_year, now_month, now_day, now_hour, now_minute, now_second, now_micro
now_year = left(now(),4)
now_month = mid(now(),6,2)
now_day = mid(now(),9,2)
now_hour = right("0" & hour(now), 2)
now_minute = right("0" & minute(now), 2)
now_second = right("0" & second(now), 2)
now_micro = right("000" & (timer * 1000) Mod 1000, 3)
'dd = now_year &"-"& now_month &"-"& now_day &" "& now_hour &":"& now_minute &":"& now_second &"."& now_micro ' ex: 2016-08-30 04:37:05.855
dd = now() ' 년-월-일 시:분:초 , 필드 데이타형식 varchar - 길이 24 ex: 2016-08-30 오전 4:38:43
'dd= date() ' 년-월-일 , 필드 10자 , 필드 데이타형식 datetime ex: 2016-08-30
'Response.Write("getdate=" & dd & "<br>")
' SMS 시작 (다이렉트 호스팅일때)
' stran_phone = "010-1234-5678" '수신자 전화번호
' 여러번호일 경우에는 ;으로 구분, 전화번호 구분자 대쉬(-)는 있거나 없거나 상관없음
' stran_callback = request("hph1")&"-"&request("hph2")&"-"&request("hph3") ' 송신자 전화번호
'stran_date = request("예약전송") ' 예약전송시에만 (예.2003-01-01 13:01)
stran_msg = "청호 , " & request("name") & "," & request("ss") & "," & request("gname") & " 온라인 예약이 접수 되었습니다."
' 전송메시지, 한글은 40자, 영문80자
guest_no = "서비스번호" ' 서비스번호
guest_key = "인증번호" ' SMS인증키
' result = request("반환값") ' 반환값 [ 성공시(OK), 실패시(에러메시지) ], 생략가능
' Response.Write("hp=" & hp & "<br>")
' Response.Write("stran_callback=" & stran_callback & "<br>")
' Response.Write("stran_msg=" & stran_msg & "<br>")
' Response.Write("guest_no=" & guest_no & "<br>")
' Response.Write("guest_key=" & guest_key & "<br>")
' 여기부터는 수정사항 없음
if trim(stran_phone) <> "" then
Set xmldoc = CreateObject("MSXML2.DOMDocument.4.0")
xmldoc.async = false
xmldoc.setProperty("ServerHTTPRequest")=True
texts = "http://sms.direct.co.kr/link/send.php?" & _
"stran_phone=" & stran_phone & "&stran_callback=" & stran_callback & _
"&stran_date=" & stran_date & "&stran_msg=" & server.URLEncode(stran_msg) & _
"&guest_no=" & guest_no & "&guest_key=" & guest_key
xmldoc.load texts
result = xmldoc.text
set xmldoc = nothing
end if
' SMS 끝
'====== 입력하기 ===========================================
SQL = "INSERT INTO application "
SQL = SQL & " (name, email, content, wdate) VALUES "
SQL = SQL & " ( '"& name &"' "
SQL = SQL & ", '"& email &"' "
SQL = SQL & ", '"& content &"' "
SQL = SQL & ", '"& dd &"' "
SQL = SQL & ")"
dbcon.Execute sql
strBody = strBody & "<table width=500 border=0 cellpadding=0 cellspacing=0><tr>"
strBody = strBody & "<td width=110 height=2 bgcolor=#4E78C2></td><td bgcolor=#4E78C2></td>"
strBody = strBody & "</tr><tr>"
strBody = strBody & "<td width=110 height=30 align=center bgcolor='#f7f7f7' style='font-size:12px;'>성<font color='#f7f7f7'>..</font>명</td>"
strBody = strBody & "<td style='padding:0 10 0 10;font-size:12px;'>"&name&"</td>"
strBody = strBody & "</tr><tr><td width=110 height=1 bgcolor='#dadada'></td><td bgcolor='#dadada'></td>"
strBody = strBody & "</tr><tr>"
strBody = strBody & "<td height=30 align=center bgcolor='#f7f7f7' style='font-size:12px;'>휴 대 폰</td>"
strBody = strBody & "<td style='padding:0 10 0 10;font-size:12px;'>"&hp&"</td>"
strBody = strBody & "</tr><tr>"
strBody = strBody & "<td width=110 height=1 bgcolor='#dadada'></td><td bgcolor='#dadada'></td>"
strBody = strBody & "</tr></table>"
Set objMail = Server.CreateObject("CDO.Message")
objMail.BodyPart.Charset = "euc-kr"
objMail.HTMLBodyPart.Charset = "euc-kr"
objMail.From = "보내는메일@happyjung.com"
objMail.To = "받는메일@happyjung.com"
objMail.Subject ="메일제목"
objMail.HTMLBody = strBody
' objMail.TextBody = strBody
objMail.send
set objMail = nothing
Response.Redirect "application_thanks.asp"
%>
### 방법2 ###
ASP 에서 메일발송하는 방법
폼메일 만들때 사용하는 소스 ^^
<%
Set objMail = Server.CreateObject("CDONTS.NewMail")
objMail.BodyPart.Charset = "euc-kr"
objMail.HTMLBodyPart.Charset = "euc-kr"
objMail.From = "보내는메일@happyjung.com"
objMail.To = "받는메일@happyjung.com"
objMail.Subject = "메일제목"
objMail.BodyFormat = 0 '0:HTML,1:TEXT
objMail.MailFormat = 0 '0:MIME,1:TEXT
objMail.Body = "내용"
objMail.importance=0 ' 메일 우선순위 0:가장빠름, 1:보통, 2:느림.
objMail.Send
Set objMail = Nothing
%>
참고자료
http://www.namul.pe.kr/entry/ASP-메일발송하기
댓글목록
등록된 댓글이 없습니다.