Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- 황광진
- 안드로이드
- 실버라이트 코리아
- winmodev
- 거제도
- 윈모데브
- 서진호
- 김춘배
- MIX10
- 데브피아
- 소년포비
- 소년포비소프트
- 스마트폰
- 신동혁
- 지승욱
- UX베이커리
- 신석현
- 윈도우모바일
- 윈도우폰
- 쉐어포인트코리아
- 루나네스
- 헤이맨
- 윈도우 모바일
- windows mobile 6.5
- 훈스닷넷
- 마이크로소프트
- 윈도데브
- 윈도우폰7
- 옴니아2
- 주신영
Archives
- Today
- Total
소년포비의 세계정복!!
[스크랩] ASP Web Based Email Using Microsoft`s CDONTS 본문
ASP Web Based Email Using Microsoft's CDONTS
The download to this tutorial has 4 working examples of Web Wiz Email Form's (CDONTS) which you can use to allow your web site visitors to send there comments or enquiries to your e-mail address or send e-mails to there own friends form your site.
However, I not going to go into how the form is written as it uses standard HTML and xxxxJavaScript to capture the users details. Instead I'm going to concentrate on the actual methods and properties the CDONTS NewMail object uses to format and then send the e-mail.
CDONTS stands for 'Collaboration Data Objects for Windows NT Server' and as the name suggest it is for NT, sorry Win9x users you don't have this component. The CDONTS component is installed when you install IIS on NT4 and Windows 2000. Although the component will run on Windows XP, Microsoft have decided to remove the component from IIS 5.1 on Windows XP, so you will have to track down a copy of the cdonts.dll and register it on the IIS web server.
To use this component to send e-mail you also need the SMTP Server that ships with IIS 4 or 5 installed on the web server. The SMTP server is usually installed by default with the standard IIS installation.
First we need to create the variables that we are going to be using in this script.
Next we need to create an instance of the 'CDONTS NewMail' object on the server.
Once the 'NewMail' object has been created on the server we can use various properties and methods of the 'NewMail' object to build the e-mail.
First we are going to use the 'From' property to let the recipient of the e-mail know who the e-mail is from. If you leave this property out or do not have a properly format e-mail address the e-mail will fail.
Now we need to place a string value representing the e-mail address of the person you want to receive the e-mail into the 'To' property of the 'NewMail' object.
The next property 'Cc' holds the e-mail address of the people you wish to receive Carbon Copies of the e-mail.
You can place one or more recipient e-mail addresses separated by either a comma (,) or a semicolon (;). Make sure all the e-mail address are properly formatted or the e-mail will fail.
This property can be left out if you don't want any carbon copies of the e-mail sent.
The 'Bcc' property holds the e-mail address of the people you wish to receive Blind Copies of the e-mail. The formatting of the e-mail addresses is the same as for the 'Cc' property above.
Again if you don't want to send any blind copies of the message you can leave this property out.
In the next line we use the 'Subject' property to set the subject of the e-mail.
As well as sending plain text e-mail's you can also format the body of the e-mail using HTML. The default is Text but if you wish to format the e-mail using HTML then you will need to use the 'BodyFormat' property with the integer value of '0' for HTML or '1' for Text.
If you leave this property out the e-mail will be sent as plain text format.
If you wish to use HTML formatting in the e-mail, as well as setting the 'BodyFormat' property above to HTML, you will also need to set the 'MailFormat' property to MIME. Again this property uses and integer value of '0' for MIME and '1' for Text.
The default is text so if your e-mail is text only you can leave this property out.
The next property were covering is the 'Body' property. This property holds the main part of the e-mail with the message you are sending.
If you have set the 'BodyFormat' property to HTML and the 'MailFormat' to MIME then you can use HTML to format your e-mail message. 'eg. <h2>Hello</h2><br><b>This is my e-mail in HTML format</b>'.
If you want to send the e-mail as text then you can just enter text instead. 'eg. Hello This is my e-mail in Text format'.
The 'Importance' property tells the mail messaging system when to schedule delivery of the e-mail.
For this property there is 3 different integer values, 0 - Low, the e-mail will be sent during times of low system use, 1 - Normal, the message is sent at regular delivery times, 2 - High, the system will attempt to send the message immediately.
If this property is left out the deafault is Normal.
Once all the properties for the e-mail are set we can now send the e-mail using the 'Send' property.
Finally once the e-mail has been sent we can close the server object releasing server resources.
There are other methods and properties of the 'NewMail CDONTS' object but to keep things simple I have tried to cover the most common properties needed to send an e-mail from your web site.
|
If you are reading this page then I shall assume that you already know a little bit about ASP and running ASP applications. |
The download to this tutorial has 4 working examples of Web Wiz Email Form's (CDONTS) which you can use to allow your web site visitors to send there comments or enquiries to your e-mail address or send e-mails to there own friends form your site.
However, I not going to go into how the form is written as it uses standard HTML and xxxxJavaScript to capture the users details. Instead I'm going to concentrate on the actual methods and properties the CDONTS NewMail object uses to format and then send the e-mail.
CDONTS stands for 'Collaboration Data Objects for Windows NT Server' and as the name suggest it is for NT, sorry Win9x users you don't have this component. The CDONTS component is installed when you install IIS on NT4 and Windows 2000. Although the component will run on Windows XP, Microsoft have decided to remove the component from IIS 5.1 on Windows XP, so you will have to track down a copy of the cdonts.dll and register it on the IIS web server.
To use this component to send e-mail you also need the SMTP Server that ships with IIS 4 or 5 installed on the web server. The SMTP server is usually installed by default with the standard IIS installation.
First we need to create the variables that we are going to be using in this script.
|
Next we need to create an instance of the 'CDONTS NewMail' object on the server.
|
Once the 'NewMail' object has been created on the server we can use various properties and methods of the 'NewMail' object to build the e-mail.
First we are going to use the 'From' property to let the recipient of the e-mail know who the e-mail is from. If you leave this property out or do not have a properly format e-mail address the e-mail will fail.
|
Now we need to place a string value representing the e-mail address of the person you want to receive the e-mail into the 'To' property of the 'NewMail' object.
|
The next property 'Cc' holds the e-mail address of the people you wish to receive Carbon Copies of the e-mail.
You can place one or more recipient e-mail addresses separated by either a comma (,) or a semicolon (;). Make sure all the e-mail address are properly formatted or the e-mail will fail.
This property can be left out if you don't want any carbon copies of the e-mail sent.
|
The 'Bcc' property holds the e-mail address of the people you wish to receive Blind Copies of the e-mail. The formatting of the e-mail addresses is the same as for the 'Cc' property above.
Again if you don't want to send any blind copies of the message you can leave this property out.
|
In the next line we use the 'Subject' property to set the subject of the e-mail.
|
As well as sending plain text e-mail's you can also format the body of the e-mail using HTML. The default is Text but if you wish to format the e-mail using HTML then you will need to use the 'BodyFormat' property with the integer value of '0' for HTML or '1' for Text.
If you leave this property out the e-mail will be sent as plain text format.
|
If you wish to use HTML formatting in the e-mail, as well as setting the 'BodyFormat' property above to HTML, you will also need to set the 'MailFormat' property to MIME. Again this property uses and integer value of '0' for MIME and '1' for Text.
The default is text so if your e-mail is text only you can leave this property out.
|
The next property were covering is the 'Body' property. This property holds the main part of the e-mail with the message you are sending.
If you have set the 'BodyFormat' property to HTML and the 'MailFormat' to MIME then you can use HTML to format your e-mail message. 'eg. <h2>Hello</h2><br><b>This is my e-mail in HTML format</b>'.
If you want to send the e-mail as text then you can just enter text instead. 'eg. Hello This is my e-mail in Text format'.
|
The 'Importance' property tells the mail messaging system when to schedule delivery of the e-mail.
For this property there is 3 different integer values, 0 - Low, the e-mail will be sent during times of low system use, 1 - Normal, the message is sent at regular delivery times, 2 - High, the system will attempt to send the message immediately.
If this property is left out the deafault is Normal.
|
Once all the properties for the e-mail are set we can now send the e-mail using the 'Send' property.
|
Finally once the e-mail has been sent we can close the server object releasing server resources.
|
There are other methods and properties of the 'NewMail CDONTS' object but to keep things simple I have tried to cover the most common properties needed to send an e-mail from your web site.
출처 : 닷넷 (.NET) 프로그래머 모임
글쓴이 : 심재운 원글보기
메모 :
'프로그램 세상 > ASP.NET' 카테고리의 다른 글
[스크랩] ASP 에서 Base64.dll 이용시 [형식이 일치하지 않습니다.: `Encode`] 에러 대처방법. (0) | 2009.03.10 |
---|---|
[스크랩] [펌] asp에서 디비작업 최적화하기 (0) | 2009.03.10 |
[스크랩] ASP 응용 프로그램의 문자열 처리 성능 향상 (0) | 2009.03.06 |
[스크랩] [펌] asp에서 디비작업 최적화하기 (0) | 2009.03.06 |
[스크랩] [펌] asp에서 디비작업 최적화하기 (0) | 2009.03.06 |