사용법

content = StripHTML(content)


Function StripHTML(oSource)


    dim Result_Text

 

    Result_text = ReplaceText(oSource," ( )+"," ")

    Result_text = Replace(Result_text,"=" & vbcrlf,"")
    Result_text = Replace(Result_text,";" & vblrcf,"")

    ' Remove the header (prepare first by clearing attributes)

   ' head 태그 안의 모든 내용을 지운다
    Result_text = ReplaceText(Result_text,"<( )*head([^>])*>","<head>")
    Result_text = ReplaceText(Result_text,"(<( )*(/)( )*head( )*>)","</head>")
    Result_text = ReplaceText(Result_text,"(<head>)[\s\S]*(</head>)","")

    ' remove all scripts (prepare first by clearing attributes)

   ' script 태그 안의 모든 내용을 지운다
    Result_text = ReplaceText(Result_text,"<( )*script([^>])*?>","<script>")
    Result_text = ReplaceText(Result_text,"(<( )*(/)( )*?script()*>)","</script>")
    Result_text = ReplaceText(Result_text,"(<script>)([^(<script>\.</script>)])*?(</script>)","")
    Result_text = ReplaceText(Result_text,"(<script>)[\s\S]*?(</script>)","")

    ' remove all styles (prepare first by clearing attributes)

   ' style 태그 안의 모든 내용을 지운다
    Result_text = ReplaceText(Result_text,"<( )*style([^>])*?>","<style>")
    Result_text = ReplaceText(Result_text,"(<( )*(/)( )*?style( )*>)","</style>")
    Result_text = ReplaceText(Result_text,"(<style>)[\s\S]*?(</style>)","")

    ' remove all object (prepare first by clearing attributes)

   ' object 태그 안의 모든 내용을 지운다
    Result_text = ReplaceText(Result_text,"<( )*object([^>])*?>","<object>")
    Result_text = ReplaceText(Result_text,"(<( )*(/)( )*?object( )*>)","</object>")
    Result_text = ReplaceText(Result_text,"(<object>)[\s\S]*?(</object>)","")

    ' Remove the link (prepare first by clearing attributes)

   ' link 태그 안의 모든 내용을 지운다
    Result_text = ReplaceText(Result_text,"<( )*link([^>])*>","<link>")
    Result_text = ReplaceText(Result_text,"(<( )*(/)( )*link( )*>)","</link>")
    Result_text = ReplaceText(Result_text,"(<link>)[\s\S]*(</link>)","")   

   ' 자바스크립트 함수 치환

    Result_text = ReplaceText(Result_text,"onclick=","xonclick=")   
    Result_text = ReplaceText(Result_text,"onmouseover=","xonmouseover=")   
    Result_text = ReplaceText(Result_text,"onmouseout=","xonmouseout=")   
    Result_text = ReplaceText(Result_text,"onchange=","xonchange=")   
    Result_text = ReplaceText(Result_text,"href=""javascript","href=""xjavascript")   

   ' span 및 div 태그의 속성을 제거

    Result_text = ReplaceText(Result_text,"<( )*span([^>])*?>","<span>")
    Result_text = ReplaceText(Result_text,"(<( )*(/)( )*?span( )*>)","</span>")

    Result_text = ReplaceText(Result_text,"<( )*div([^>])*?>","<div>")
    Result_text = ReplaceText(Result_text,"(<( )*(/)( )*?div( )*>)","</div>")  

 

   ' input 태그를 지운다

    Result_text = ReplaceText(Result_text,"<( )*input([^>])*?>","")
           
    ' Remove remaining tags like <a>, links, images, comments etc - anything thats enclosed inside < >

   ' 허용태그 이외의 태그 제거


    Result_text = ReplaceText(Result_text,"<[^(image|a|div|span|table|tr|td|li|p)]*?>","")
   
    ' Thats it.
    StripHTML = Result_Text
End Function

 

Function ReplaceText(str1, patrn, replStr)
   Dim regEx
   Set regEx = New RegExp
   with regEx
      .Pattern = patrn
      .IgnoreCase = True
      .Global = True
   end with
   ReplaceText = regEx.Replace(str1, replStr)
End Function

 

 

 

출처 : Tong - jupiter0410님의 § Program §통

크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by 멍멍대왕

검색어 : ([0-9][0-9]|[0-9])    12 or 1등의 2자리 또는 한자리 숫자 검색
바꿀말 : TEST=\0      \0은 검색어에서 검색된 내용

크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by 멍멍대왕

가장 기본적인 방법은 다음과 같다.
<%
sUrl = "http://www.ecplaza.net/"
set oHttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
oHttp.Open "GET", sUrl, False
oHttp.Send ""
Response.Write oHttp.ResponseText
Set oHttp = Nothing
%>

GET 메쏘드로 갖고온 HTML을 화면에 출력하는 루틴이다.
게시판등에 글을 쓰거나 할 때는 POST 메쏘드를 사용하는데 이 방법도 가능한다.

<%
sUrl = "http://river.ecplaza.net/form.asp"
set oHttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
oHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oHttp.Open "POST", sUrl, False
oHttp.Send "subject=test&contents=message+body"
Response.Write oHttp.ResponseText
Set oHttp = Nothing
%>


오류 처리는 Send 메쏘드를 호출하기 전에 On Error Resume Next를 적어주고 오류발생여부를 체크하면 된다.

<%
sUrl = "http://river.ecplaza.net/form.asp"
set oHttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
oHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
On Error Resume Next


oHttp.Send "subject=test&contents=message+body"
If Err Then
Response.Write "Error:" & oHttp.ParseError.URL & "<br>" & oHttp.ParseError.Reason
Else
Response.Write oHttp.ResponseText
End If
Set oHttp = Nothing
%>
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by 멍멍대왕

<%

' ===========================
'  Function to GetHTMLBin
' ===========================
Function GetHTMLBin(URLaddress)
Dim Http
Set Http = CreateObject("Microsoft.XMLHTTP")
Http.Open "GET", URLaddress, False
Http.Send
GetHTMLBin = Http.responseBody
Set Http = Nothing
End Function

' ===========================
'  Function to BinToText
' ===========================
Function BinToText(varBinData, intDataSizeInBytes)    ' as String
Const adFldLong = &H00000080
Const adVarChar = 200
Set objRS = CreateObject("ADODB.Recordset")
objRS.Fields.Append "txt", adVarChar, intDataSizeInBytes, adFldLong
objRS.Open
objRS.AddNew
objRS.Fields("txt").AppendChunk varBinData
BinToText = objRS("txt").Value
objRS.Close
Set objRS = Nothing
End Function

GetURL = "http://www.naver.com/"

HTMLBin = GetHTMLBin(GetURL)
html = BinToText(HTMLBin,32000) 

%>
<%=html%>

ResponseText를 이용하여 값을 받아서 출력하면 한글이 깨지게 됩니다. 그래서 바이너리타입으로 값을 전송하여 변환하는 함수를 이용하여 출력하는 방식입니다.

크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by 멍멍대왕
1. meta 태그를 추가
(1)
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="wed, 04 jul 1973 16:00:00 gmt">

(2)
<meta http-equiv='Content-type' content='text/html; charset=utf-8'>
<meta http-equiv="cache-control" content="no-cache, must-revalidate">
<meta http-equiv="pragma" content="no-cache">


2. 이미지에 파라미터값을 넣어준다.
<img src="test.asp?t=<%=timer%>" border="0">


이렇게 하면 이미지값이 자동으로 변동되기 때문에 캐시에서 값을 불러오지 않고 새로 불러올 수가 있다.
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by 멍멍대왕



VBScript 레퍼런스 인스톨 버전입니다. (영문)
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by 멍멍대왕



ASP에서 가끔 FTP를 사용해야할때(자료의 원격지 이동등) 유용하게 사용할 수 있는 컴포넌트입니다.

ASPFTP 라는 이름이며, 압축파일에는 설치법과 예제 , 그리고 dll 파일이 포함되어 있습니다.
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by 멍멍대왕
Data Type Mapping Minimize

The following table shows the ADO Data Type mapping between Visual Basic, Access, SQL Server, Oracle, and the .NET Framework.

ADO
DataType
Enum
ADO
DataType
Enum
Value
.NET
Framework
SQL
Server
Size Access Oracle Visual
Basic
6.0
adBigInt 20 Int64
SqlDbType.BigInt 10
OleDbType.BigInt
11
bigint 9 8     Variant
adBinary 128 Byte[]
SqlDbType.VarBinary 10
OleDbType.Binary
11
binary
timestamp
50
8
  Raw 7 Variant
adBoolean 11 Boolean
SqlDbType.Bit 10
OleDbType.Boolean
11
bit
1
2
 
 
YesNo
  Boolean
adBSTR 8 String
OleDbType.BSTR
11
         
adChapter 136 (DataReader)          
adChar 129 String
SqlDbType.Char 10
OleDbType.Char
11
char X   Char String
adCurrency 6 Decimal
SqlDbType.Money 10
OleDbType.Currency
11
money
smallmoney
 
8
4
0
 
 
Currency
  Currency
adDate 7 DateTime
OleDbType.DBDate
11
 
0
 
DateTime
2
  Date
adDBDate 133 DateTime
OleDbType.DBDate
11
         
adDBFileTime 137 DBFileTime 11          
adDBTime 134 DateTime
OleDbType.DBTime
11
         
adDBTimeStamp 135 DateTime
SqlDbType.DateTime 10
OleDbType.DBTimeStamp
11
datetime
 smalldatetime
 
8
4
0
 
 
DateTime
1
Date Date
adDecimal 14 Decimal
OleDbType.Decimal
11
      Decimal 7 Variant 6
adDouble 5 Double
SqlDbType.Float 10
OleDbType.Double
11
float  
8
0
 
 
Double
Float Double
adEmpty 0 Empty 11          
adError 10 External-Exception
OleDbType.Error
11
         
adFileTime 64 DateTime
OleDbType.Filetime
11
         
adGUID 72 Guid
SqlDbType.UniqueIdentifier 10
OleDbType.Guid
11
uniqueidentifier5 16  
 
ReplicationID
2,3 
  Variant
adIDispatch 9 Object
OleDbType.IDispatch
11
         
adInteger 3 Int32
SqlDbType.Int 10
OleDbType.Integer
11

identity 4
int
 

4
4
 
 
AutoNumber
Long Integer
Int 7 Long
adIUnknown 13 Object
OleDbType.IUnknown
11
         
adLongVarBinary 205 Byte[]
SqlDbType.VarBinary 10
OleDbType.LongVarBinary
11
image 2147483647  
 
OLEObject
Long Raw 7
Blob
8
Variant
adLongVarChar 201 String
SqlDbType.VarChar 10
OleDbType.LongVarChar
11
text 2147483647  
Memo 1, 2
Hyperlink
1, 2
Long 7
Clob
8
String
adLongVarWChar 203 String
SqlDbType.NText 10
OleDbType.VarWChar
11
ntext 5 1073741823  
Memo 3
Hyperlink
3
NClob 8 String
adNumeric 131 Decimal
SqlDbType.Decimal 10
OleDbType.Decimal
11
decimal
numeric
 
9
 
 
 
Decimal
3
Decimal
Integer
Number
SmallInt
Variant 6
adPropVariant 138 Object
OleDbType.PropVariant
11
         
adSingle 4 Single
SqlDbType.Real 10
OleDbType.Single
11
real 4  
 
Single
  Single
adSmallInt 2 Int16,
SqlDbType.SmallInt 10
OleDbType.SmallInt
11
smallInt 2  
 
Integer
  Integer
adTinyInt 16 Byte
OleDbType.TinyInt
11
         
adUnsignedBigInt 21 UInt64
OleDbType.UnsignedBigInt
11
         
adUnsignedInt 19 UInt32
OleDbType.UnsignedInt
11
         
adUnsignedSmallInt 18 UInt16
OleDbType.UnsignedSmallInt
11
         
adUnsignedTinyInt 17 Byte
SqlDbType.TinyInt 10
OleDbType.UnsignedTinyInt
11
tinyInt 1  
 
Byte
  Byte
adUserDefined 132            
adVarBinary 204 Byte[]
SqlDbType.VarBinary 10
OleDbType.VarBinary
11
varbinary 50  
 
ReplicationID
1
  Variant
adVarChar 200 String
SqlDbType.VarChar 10
OleDbType.VarChar
11
varchar X  
 
Text
1, 2
VarChar String
adVariant 12 Object
SqlDbType.Variant 10
OleDbType.Variant
11
sql_variant 9 8016   VarChar2 Variant
adVarNumeric 139 OleDbType.VarNumeric 11          
adVarWChar 202 String
SqlDbType.NVarChar 10
OleDbType.VarWChar
11
nvarchar 5 X  
 
Text
3
NVarChar2 String
adWChar 130 String
SqlDbType.NChar 10
OleDbType.WChar
11
nchar 5 X     String

Top of Page

1 - ODBC Driver (3.51.171300):  Microsoft Access Driver (*.mdb),    Access 97 (3.5 format)
2 - OLE DB Provider: Microsoft.Jet.OLEDB.3.51,   Access 97 (3.5 format)  
3 - OLE DB Provider: Microsoft.Jet.OLEDB.4.0 ,   Access 2000 (4.0 format)
4 - OLE DB Provider: SQLOLEDB,   SQL Server 6.5
5 - OLE DB Provider: SQLOLEDB,   SQL Server 7.0 +
6 - The VB Decimal data type can only be used within a Variant, that is, you cannot declare
     a VB variable to be of type Decimal.
7 - Oracle 8.0.x   Note: DECIMAL and INT are synonyms for NUMBER and NUMBER(10) respectively.
8 - Oracle 8.1.x
9 - OLE DB Provider: SQLOLEDB, SQL Server 2000 +
10 - SQL Server .NET Data Provider (via System.Data.SqlTypes)
11 - OLE DB .NET Data Provider (via System.Data.OleDb)

Note: "User Defined" data types (e.g.  ID, TID, EmpID, SysName) are not shown on this diagram.

크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by 멍멍대왕
보통 SP에서 임시테이블을 사용할 경우에 ASP에서는 해당 레코드셋을 받아올 수 없다고 생각하는 프로그래머들이 의외로 많다. 하지만 그것은 틀린 생각이다. SP를 좀 더 명확하게 작성해주면 된다.

[code type="sql"]
Create Proc spTestB AS
DECLARE @Results Table (ID TinyInt)
INSERT INTO @Results SELECT ID FROM FileList

SELECT ID FROM @Results
GO
[/code]
예를 들어서 위와같은 SP가 있다고 하고 ASP 페이지에서

Set List = objConn.Execute("Exec TestB")

를 실행했다고 하면 대부분 "개체가 닫혀있으면 작업이 허용되지 않습니다." 라는 에러 메세지를 보게 된다.

물론 그냥 SQL 쿼리 분석기에서 실행하면 아주 잘 동작한다.  하지만 ASP에서 해당 레코드셋을 받아오려고 하면 동작하지 않는다. 이는 위의 테이블이 임시테이블이던지 혹은 실제 테이블이던지 상관없다.

왜 그럴까? 이는 우리가 결과를 리턴받기를 원하는 레코드셋을 제대로 받아오지 못하기 때문이다.

두가지 해결방법이 있는데..

1. OLE DB를 사용하지 않고 ODBC를 사용하면 해결된다. - 하지만 호스팅을 이용한다고 하면 이렇게 쓸수는 없지 않은가...

2. SP 자체를 바꾸면 된다 ^^;

[code type="sql"]
Create Proc spTestB AS
SET NOCOUNT ON
DECLARE @Results Table (ID TinyInt)
INSERT INTO @Results SELECT ID FROM FileList

SET NOCOUNT OFF
SELECT ID FROM @Results
GO
[/code]

두번째 SP에서는 SET NOCOUNT ON 과 SET NOCOUNT OFF의 위치를 주의해서 보면 됩니다.

SET NOCOUNT에 대해서는 MSSQL 도움말을 참고하기 바랍니다.
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by 멍멍대왕
CursorType 및 상수

앞에 나온 속성중에서 CursorType 및 상수에 대해 알아본다

앞에서 레코드셋 즉, 데이타를 다루는 단위가 레코드라고 했다. 그러면 무엇으로 현재레코드를 알 수 있을까? 바로 레코드포인트라는 것이 있어서 항상 현재레코드를 가리키도록 되어 있다.

우리는 이 레코드포인트를 이동하면서 필요한 데이타 작업을 할 수 있다. 이때 레코드포인트를 이동시켜 주는 것이 Cursor이다. 윈도우나 워드에서 화면/메뉴를 이동할 때 쓰는 Cursor와 비슷하다.

이는 레코드셋을 열기 전에 지정되어야 하며 4가지가 있다. 지정하지 않으면 ForwardOnly(0)이 지정된다.

* 적용방법 : 보통은 생략하든지 adOpenForwardOnly를 사용하면 되고 목록보기에서는 페이지관련 속성(pagesize,pagecount,absolutepage)을 사용할 수 있는 adOpenKeyset, adOpenStatic 을 사용하면 된다.


커서타입 상수 내 용
adOpenForwardOnly 0 디폴트 타입,읽기만 가능,가장 빠르다,전방향이동만 가능
순서대로 한번씩 참조할 경우 편리하다
adOpenKeyset 1 읽기/쓰기 가능,양방향 이동 가능, 다른 사용자 추가,삭제는 볼 수 없다
adOpenDynamic 2 읽기/쓰기 가능,모든 이동 가능,다른 사용자 추가,삭제,수정을 볼 수 있다,성능상 많은 부담이 있다
adOpenStatic 3 읽기/쓰기 가능,양방향 이동 가능, 본인외 다른 레코드셋 추가,삭제는 볼 수 없다

사.용.방.법
1. 상수값을 사용하는 방법  

Set Rs=Server.CreateObject("ADODB.Recordset")
ConnString= "Provider=Microsoft .Jet.OLEDB.4.0;Data Source=d:/test/member.mdb;"
SQL="Selcect* from 테이블이름"
Rs.Open SQL, ConnString, 3

또는

Set Rs=Server.CreateObject("ADODB.Recordset")
CursorType=3
ConnString= "Provider=Microsoft .Jet.OLEDB.4.0;Data Source=d:/test/member.mdb;"
SQL="Selcect* from 테이블이름"
Rs.Open SQL, ConnString


2. 상수를 사용하는 방법
ADO상수를 사용하려면 (즉,adOpenForwardOnly와 같이)
상수를 정의해둔 상수화일을 Server Side Include로 adovbs.inc화일을 포함하여야 한다

<!-- #include file="폴더\adovbs.inc" -->
..............
Set Rs=Server.CreateObject("ADODB.Recordset")
ConnString= "Provider=Microsoft .Jet.OLEDB.4.0;Data Source=d:/test/member.mdb;"
SQL="Selcect* from 테이블이름"
Rs.Open SQL, ConnString, adOpenStatic

또는

<!-- #include file="common\adovbs.inc" -->
.............
Set Rs=Server.CreateObject("ADODB.Recordset")
CursorType="adOpenStatic"
ConnString= "Provider=Microsoft .Jet.OLEDB.4.0;Data Source=d:/test/member.mdb;"
SQL="Selcect* from 테이블이름"
Rs.Open SQL, ConnString



*만약 레코드셋 객체를 통해 수정/삭제/등록을 하고자 하면 반드시 레코드셋에 대한 락 수준을 지정을 해야한다.
(ADO연습 데이타 등록 부분 - 레코드셋 객체를 통한 데이타 등록 참고)

락타입 상수 내 용
adLockReadOnly 1 읽기전용(수정불가)
adLockPessimistic 2 레코드단위, 편집 시작 순간부터
adLockOptimistic 3 레코드 단위, update 메서드 순간
adLockBatchOptimistic 4 배치갱신모드 요구


ADO에서 사용하는 상수는 이외에도 많이 있다. 이 상수값들은 파일하나로 정의되었으며
위치는 c:\program files\common files\system\ado아래에 있다.

사용을 위해 웹사이트(가상디렉토리)내에 폴더를 만들어 복사해서 두고 쓰면 된다.

크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by 멍멍대왕



Base64 Encoding Library 2.04

Properties:
  • LastCount As Double. Returns the amount of time that the last operation took, in seconds.

Methods:

  • Encode (strDatos As String) As String. Encodes data passed in strDatos and returns the result in a String var.
  • EncodeArr (arrDatos() As Byte) As String. Encodes data passed in the array Datos and returns the result in a String var.
  • EncodeArrArr (arrDatos() As Byte). This method will take data to encode from arrData() and will return the encoded data in the same array. It's the fastest one.
  • EncodeFromFile (strPath As String) As String. Encodes the file specified in strPath and returns the result in a String var.
  • Decode (strDatos As String) As String. Decodes data passed in strDatos and returns the result in a String var.
  • DecodeArr (strDatos As String). Decodes data passed in strDatos and returns the result in an array.
  • DecodeArrArr (arrDatos() As Byte). This method will take data to decode in arrDatos() and will return the decoded data in the same array. It's the fastest one.
  • DecodeToFile (strDatos As String, strPath as String). Decodes data passed in strDatos and saves the result to the file given in strPath. If another file exists with the same name, it will try to overwrite it.

사용방법

1. 레지스트리 등록 (시작->실행->cmd 하신후 프럼프트에서 regsvr32 c:\base64.dll)

2. IIS재시작

* 인코딩
Set objEncode = Server.CreateObject("Base64Lib.Base64")
strEncodeData = objEncode.Encode(strContents)
Set objEncode = Nothing
Response.Write strEncodeData

* 디코딩
Set objDecode = Server.CreateObject("Base64Lib.Base64")
strDecodeData = objDecode.Decode(strContents)
Set objDecode = Nothing
Response.Write strDecodeData


※ 한글지원도 잘 됩니다.
  삭제시에는 regsvr32 -u c:\base64.dll 하시면 됩니다.
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by 멍멍대왕
1. 모든 ASP 코드 페이지 첫줄에 다음과 같은 코드를 추가합니다
<% @LANGUAGE='VBSCRIPT' CODEPAGE='65001' %>
2. Meta 테그를 다음과 같이 추가 합니다.
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
3. 에디트플러스나 울트라 에디터에서 수정후 저장할 때 반드시 Encoding 방식을 UTF-8 로 저장합니다
4.DB Insert/Update 시 숫자 타입을 제외한 모든 대상에 N을 추가 합니다
Insert [into] table_name [(column_list)] Value N[data_value]
5.DB like 검색시 N 추가
6. 파일 첨부 DEXT Upload사용(영문으로 설치)
SET uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = Server.MapPath(ESP_BBS_DATA)
uploadform.CodePage = 65001
wFileSize = 0
rAttachment = uploadform("txtAttachFile")

If Len(rAttachment) > 0 Then
wFileName =  uploadform("txtAttachFile").FileName
wFileSize =  uploadform("txtAttachFile").FileLen

response.write uploadform.DefaultPath
rAttachment = uploadform.SaveAs(uploadform.DefaultPath & "" & wFileName , False)
rAttachment = UploadForm.LastSavedFileName
End If
7. 파일 다운로드
<% @LANGUAGE='VBSCRIPT' CODEPAGE='65001' %>
<%
'Response.Charset = "UTF-8"
filepath = Request.QueryString("txtFilepath") '// form으로 파라메터 전달해야 함.
filename = Request.QueryString("txtFilename")'// form으로 파라메터 전달해야 함.
If filepath = "" Then
filepath=server.MapPath( Request.QueryString("txtFilename"))
filename = Mid(filepath, InStrRev(filepath, "")+1)
Else
filepath=server.MapPath(filepath)
filename =  Request.QueryString("txtFilename")
If filename = "" Then
  filename = Request.QueryString("txtattachment")
End If
End If

filepath = filepath &"" & filename
Call FileDown
%>
<%
Sub FileDown
Response.Buffer = False
Response.ContentType = "application/x-msdownload"
'ContentType 를 선언합니다.
'server.HTMLEncode
'server.URLPathEncode
Response.AddHeader "Content-Disposition","attachment; filename=" & server.URLPathEncode(filename) '//server.URLPathEncode 사용해야만 파일명 재대로 출력
'헤더값이 첨부파일을 선언합니다.
Set objStream = Server.CreateObject("ADODB.Stream")
'Stream 을 이용합니다.
objStream.Open
'무엇이든 Set 으로 정의했으면 열어야 겠지요^^
objStream.Type = 1
objStream.LoadFromFile filepath
'절대경로 입니다.
download = objStream.Read
Response.BinaryWrite download
'이게 보통 Response.Redirect 로 파일로 연결시켜주는 부분을 대신하여 사용된 것입니다.
Set objstream = nothing
'초기화시키구요.
End Sub
%>
<%
Sub DEXTDown   ' DEXT.FileDownload 는 일본어 OS에 영문으로 설치시 한글파일 찾지 못함.(DextUpload 2.0까지는 그랬음)
'On Error Resume Next
Response.Buffer = False
Response.AddHeader "Content-Disposition","inline;filename=" &  server.URLPathEncode(filename)
set objFS = Server.CreateObject("Scripting.FileSystemObject")

set objF = objFS.GetFile(filepath)

Response.AddHeader "Content-Length", objF.Size
set objF = nothing
set objFS = nothing
Response.ContentType = "application/x-msdownload"
Response.CacheControl = "public"
Set objDownload = Server.CreateObject("DEXT.FileDownload")
objDownload.Download filepath
Set uploadform = Nothing
End Sub
%>
8. CDO Mail발송
Dim iMsg
Dim iConf
Dim Flds
Dim strHTML
Const cdoSendUsingPort = 2 '1:로컬, 2:외부 smtp
set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10

Flds.Update
Set iMsg.Configuration = iConf
iMsg.To = "xxxx@xxx.ccx" 'ToDo: Enter a valid email address.
iMsg.From = "xxxx@xxx.ccx"  'ToDo: Enter a valid email address.
iMsg.Subject = "This is a test CDOSYS message (Sent via Port 25)"
'iMsg..TextBody = strHTMLMsg '// 텍스트
iMsg.HTMLBody = strHTML  '// HTML 제목 깨짐 발생..

iMsg.BodyPart.Charset="UTF-8" '/// 한글을 위해선 꼭 넣어 주어야 합니다.
iMsg.HTMLBodyPart.Charset="UTF-8" '/// 한글을 위해선 꼭 넣어 주어야 합니다.
iMsg.Send
End With
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
9. ASP에서 배달 확인/ 읽음 확인 구현 방법 http://tong.nate.com/windeo/5767827

<%
Set oMsg = CreateObject("CDO.Message")
oMsg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
‘ 생성되는 메시지가 SMTP pickup 디렉터리가 아닌 SMTP 서비스로 전송되게 합니다.
oMsg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "이름"
oMsg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xxxxx"
oMsg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "seo-msg-01"
‘ 생성되는 메시지의 서버, 사서함 및 암호
oMsg.Configuration.Fields.Update

oMsg.From = "smpark@microsoft.com"
oMsg.To = "smpark@microsoft.com"

oMsg.Subject = "읽음 확인 및 배달 확인"
oMsg.DSNOptions = 14
‘ 이 메시지의 배달 상태 확인(delivery status notification:DSN)값으로 14는 배달 성공, 실패 및 지연시
‘ 확인메시지 생성
oMsg.Fields("urn:schemas:mailheader:return-receipt-to") = smpark@microsoft.com <mailto:smpark@microsoft.com>
‘ 받는 사람이 이 메시지를 열었을 때 읽음 확인 메시지가 여기에서 지정된 사람에게 보내집니다.
oMsg.Fields("urn:schemas:mailheader:disposition-notification-to") = smpark@microsoft.com <mailto:smpark@microsoft.com>
‘ MDN(Message Disposition Notification)은 이 메시지의 확인 메시지가 리턴 될 수신자를 지정합니다.
‘ MDN에 대하여는 Request for Comments (RFC) 2298에 자세히 설명됩니다.
oMsg.TextBody = " SMTP 서버를 통한 읽음 확인 및 배달 확인 메시지"
oMsg.Fields.Update
oMsg.Send

Set oMsg = Nothing
%>
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by 멍멍대왕