如何使用 Cdosys.dll 库使用ASP发送邮件带附件
1<%@ Language=VBScript CODEPAGE=65001%>
2<% Response.Buffer=True %>
3<%
4'Collaboration Data Objects, version 1.2.1(CDO)
5'http://www.microsoft.com/downloads/details.aspx?FamilyId=2714320D-C997-4DE1-986F-24F081725D36&displaylang=en
6'-----------------第一步 创建对象 cdosys.dll cdoex.dll 此文件在WINDOWS SYSTEM32文件夹下-------------
7%>
8<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
9<html xmlns="http://www.w3.org/1999/xhtml" >
10<head>
11<meta content="Geovin Du" name="Author">
12<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
13<title>™Du Computer information Technology Co,.Ltd® is engaged in applied software design, development and
14service.We provide system solution to fund flow, information flow, human
15resource flow, material flow and control flow.勝利は仕事部屋である貴方にご光来を賜ることを歓迎,®geoVI 일
16방,고향 geocVi 스튜디오는 缔友计算机信息技术有限公司,Du Computer information Technology Co,.Ltd.Geovin Du.</title>
17<!--geovindu@gmail.com 2007-08-10 Systems Solution for fund flow,and Information flow, and Talent people flow, and Material flow, and Control flow, and Human Resource.Applied software development, design and service。
18
19<META HTTP-EQUIV="REFRESH" CONTENT="11; URL=http://www.dusystem.com/index.htm"> 2006-03-12 designer Geovin Du-->
20<meta name="description" content="涂聚文,缔友计算机信息技术有限公司,经营信息流,物流,人力资源流,资本流的系统解决方案的开发与设计和服务,geoVI studio.Geovin Du. Systems Solution to Fund flow,and Information flow,and Material flow,and Control flow,and Human Resource.Applied software development,design and service。.">
21<meta name="description" content="Study,Communicate。 ">
22<meta name="Robots" content="all index follow ">
23<meta name="Author" content="涂聚文" />
24<meta name="keywords" content="Chinea,Guangdong Province,Shenzhen city,Nanshan District,Hi-teach industry Park, geoVI studio,Geovin Du,Systems Solution.勝利は仕事部屋である貴方にご光来を賜ることを歓迎,the original affiliation, Jiangxi Province, the Ji'an city, YongFeng coutry, Ouyang's hometown. Discussion forum, friend reason person, English, Japanese language, Korean language The music appreciation, Wan Nian calendar, the English salon, the trade market, the information, the telecommunication electron, the electric appliance, the currency foreign exchange, the news, the book, by talk, the fable, the fairy tale, the novel, the sketch philosophy, the philosophy, the national studies, the poem, the word, the prose, the tune, manages the creativity, the software technology, sound, the picture, the image data warehouse, C++, C.NET, WEB,JAVA, J2EE XML, the HTML, software engineering, the physiological, keeping in good health, the traveling, lives,geocVi のスタジオはgeovindu, 中国のGuangdong の地 域,Shenzhen のNanShan 地区すなわち高く新しい技術的な企業の 開発の地帯すなわち元の加入すなわちJiangxi の地域すなわち Ji'an 都市, 故郷coutry YongFeng Ouyang's のへ, あな たを歓迎する。議論のフォーラムすなわち友人の理由人, 英語す なわち日本語の言語すなわち韓国語の言語は 音楽感謝すなわ ちNian の弱々しいカレンダーすなわち英国の大広間すなわち貿易 市場すなわち情報すなわちテレコミュニケーションの電子すなわ ち電気電気器具すなわち通貨の外国為替すなわちニュースすなわ ち本, 話によって, fable のおとぎ話すなわち小説すなわちスケ ッチの哲学すなわち哲学は, 国民調査する, 詩すなわち単語すな わち散文すなわち調子, 管理する創造性すなわちソフトウェア技 術すなわち音すなわち映像すなわちイメージ・データの倉庫 , C++, C.NET の網, ジャワ, J2EE XML, html のよい健康すなわ ち移動, 生命で保つソフトウエア工学すなわち生理学を,®geoVI 일 방 ™고향 geocVi 스튜디오는 geovindu, 중국 의 Guangdong 지방, Shenzhen 의 NanShan 지역, 높은 새로운 기술 적인 공업 발달 지역, 원래 affiliation, Jiangxi 지방 , Ji'an 도시, coutry YongFeng, Ouyang's에, 너를 환 영한다. 면담 공개토론, 친구 이유 사람, 영어, 일본 언어, 한 국 언어는 음악 감사, Nian 병약한 달력, 영국 살롱, 무역 시장, 정보, 원거리 통신 전자, 전기기구, 통화 외국 교환, 뉴 스, 책, 이야기의옆에,fable 의 요전같은 총계, 소설, 밑그림 철학, 철학은, 동포 공부한다, 시, 낱말, 산문, 곡, 처리한다 독창성, 소프트웨어 기술, 소리, 그림,심상 자료 창고 , C++, C.NET 의 웨브, 자바, J2EE XML, HTML 의 건강, 여행, 일생안에 지키는 소프트웨어 기술설계, 생리를">
25 <link rel="stylesheet" href="css/style.css" type="text/css">
26 <link rel="stylesheet" href="css/shadow.css" type="text/css">
27<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
28<link rel="icon" href="favicon.ico" type="image/ico" />
29<link rel="Bookmark" href="favicon.ico">
30 <link rel="home" title="Home" href="http://www.dusystem.com" />
31<title>cdo send mail</title>
32</head>
33
34<body>
35<%
36'-----------------第一步 创建对象-------------
37Dim oMsg
38Set oMsg = Server.CreateObject("CDO.Message")
39'-----------------第二步 进行设置-------------
40oMsg.From = "geovindu@dupcit.com" '设置发信人的邮箱
41oMsg.To = "geovindu@gmail.com" '设置收信人的邮箱
42oMsg.Subject = "这是邮件标题CDO發郵件測試"
43'抄送,你可以发任意数量
44oMsg.CC = """geovindu-1"" <ginhongzhao@163.com>, ""geovindu-2"" <geovindu@126.com>"
45'密件抄送,也可以发任意数量
46oMsg.BCC = """geovindu-1"" <ginhongzhao@gmail.com>, ""geovindu-2"" <geovindu@163.com>"
47
48
49Dim strHTML
50strHTML = "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">"
51strHTML = strHTML & "<html xmlns=""http://www.w3.org/1999/xhtml"">"
52strHTML = strHTML & " <head>"
53strHTML = strHTML & " <title>嵌入图片和其它文件</title>"
54strHTML = strHTML & " </head>"
55strHTML = strHTML & " <body><p>"
56strHTML = strHTML & " <img src=""cid:previous.png""></p><p>嵌入一幅图片</p><a href=http://www.w3.org/WAI/WCAG1AA-Conformance target=_blank>geovindu</a>"
57strHTML = strHTML & " </body>"
58strHTML = strHTML & "</html>"
59'设置信件内容是HTML格式
60oMsg.HTMLBody = strHTML
61'将多媒体文件添加进邮件内容内,并定义一个内容ID为previous.png
62'HTML使用该ID来引用邮件内容中的多媒体文件
63oMsg.AddRelatedBodyPart "C:\Documents and Settings\geovindu\My Documents\My Pictures\previous.png", "previous.png", cdoRefTypeId
64'oMsg.TextBody = "这是邮件正文,可以多写一点!!!"
65'-----------------第三步 远程配置-------------
66Dim oConfig,strNameSpace
67Set oConfig = Server.CreateObject("CDO.Configuration")
68strNameSpace = "http://schemas.microsoft.com/cdo/configuration/"
69oConfig.Fields(strNameSpace & "smtpserver") = "mail.dupcit.com"
70oConfig.Fields(strNameSpace & "smtpserverport") = 25
71oConfig.Fields(strNameSpace & "smtpaccountname") = "geovindu@dupcit"
72'注意下面的配置应该与oMsg.From相同
73oConfig.Fields(strNameSpace & "sendemailaddress") = "geovindu@dupcit.com"
74oConfig.Fields(strNameSpace & "smtpauthenticate") = 1
75oConfig.Fields(strNameSpace & "sendusername") = "geovindu@dupcit.com"
76oConfig.Fields(strNameSpace & "sendpassword") = "password"
77oConfig.Fields(strNameSpace & "Smtpusessl") = False
78oConfig.Fields(strNameSpace & "sendusing") = 2
79oConfig.Fields.Update() '使配置生效
80Set oMsg.Configuration = oConfig '赋给oMsg.Configuration属性
81'-----------------第四步 执行发送-------------
82oMsg.Send()
83Set oMsg = Nothing '发送成功后释放对象
84Response.Write("成功发送邮件!!!")
85%>
86
87</body>
88
89</html>
90
2<% Response.Buffer=True %>
3<%
4'Collaboration Data Objects, version 1.2.1(CDO)
5'http://www.microsoft.com/downloads/details.aspx?FamilyId=2714320D-C997-4DE1-986F-24F081725D36&displaylang=en
6'-----------------第一步 创建对象 cdosys.dll cdoex.dll 此文件在WINDOWS SYSTEM32文件夹下-------------
7%>
8<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
9<html xmlns="http://www.w3.org/1999/xhtml" >
10<head>
11<meta content="Geovin Du" name="Author">
12<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
13<title>™Du Computer information Technology Co,.Ltd® is engaged in applied software design, development and
14service.We provide system solution to fund flow, information flow, human
15resource flow, material flow and control flow.勝利は仕事部屋である貴方にご光来を賜ることを歓迎,®geoVI 일
16방,고향 geocVi 스튜디오는 缔友计算机信息技术有限公司,Du Computer information Technology Co,.Ltd.Geovin Du.</title>
17<!--geovindu@gmail.com 2007-08-10 Systems Solution for fund flow,and Information flow, and Talent people flow, and Material flow, and Control flow, and Human Resource.Applied software development, design and service。
18
19<META HTTP-EQUIV="REFRESH" CONTENT="11; URL=http://www.dusystem.com/index.htm"> 2006-03-12 designer Geovin Du-->
20<meta name="description" content="涂聚文,缔友计算机信息技术有限公司,经营信息流,物流,人力资源流,资本流的系统解决方案的开发与设计和服务,geoVI studio.Geovin Du. Systems Solution to Fund flow,and Information flow,and Material flow,and Control flow,and Human Resource.Applied software development,design and service。.">
21<meta name="description" content="Study,Communicate。 ">
22<meta name="Robots" content="all index follow ">
23<meta name="Author" content="涂聚文" />
24<meta name="keywords" content="Chinea,Guangdong Province,Shenzhen city,Nanshan District,Hi-teach industry Park, geoVI studio,Geovin Du,Systems Solution.勝利は仕事部屋である貴方にご光来を賜ることを歓迎,the original affiliation, Jiangxi Province, the Ji'an city, YongFeng coutry, Ouyang's hometown. Discussion forum, friend reason person, English, Japanese language, Korean language The music appreciation, Wan Nian calendar, the English salon, the trade market, the information, the telecommunication electron, the electric appliance, the currency foreign exchange, the news, the book, by talk, the fable, the fairy tale, the novel, the sketch philosophy, the philosophy, the national studies, the poem, the word, the prose, the tune, manages the creativity, the software technology, sound, the picture, the image data warehouse, C++, C.NET, WEB,JAVA, J2EE XML, the HTML, software engineering, the physiological, keeping in good health, the traveling, lives,geocVi のスタジオはgeovindu, 中国のGuangdong の地 域,Shenzhen のNanShan 地区すなわち高く新しい技術的な企業の 開発の地帯すなわち元の加入すなわちJiangxi の地域すなわち Ji'an 都市, 故郷coutry YongFeng Ouyang's のへ, あな たを歓迎する。議論のフォーラムすなわち友人の理由人, 英語す なわち日本語の言語すなわち韓国語の言語は 音楽感謝すなわ ちNian の弱々しいカレンダーすなわち英国の大広間すなわち貿易 市場すなわち情報すなわちテレコミュニケーションの電子すなわ ち電気電気器具すなわち通貨の外国為替すなわちニュースすなわ ち本, 話によって, fable のおとぎ話すなわち小説すなわちスケ ッチの哲学すなわち哲学は, 国民調査する, 詩すなわち単語すな わち散文すなわち調子, 管理する創造性すなわちソフトウェア技 術すなわち音すなわち映像すなわちイメージ・データの倉庫 , C++, C.NET の網, ジャワ, J2EE XML, html のよい健康すなわ ち移動, 生命で保つソフトウエア工学すなわち生理学を,®geoVI 일 방 ™고향 geocVi 스튜디오는 geovindu, 중국 의 Guangdong 지방, Shenzhen 의 NanShan 지역, 높은 새로운 기술 적인 공업 발달 지역, 원래 affiliation, Jiangxi 지방 , Ji'an 도시, coutry YongFeng, Ouyang's에, 너를 환 영한다. 면담 공개토론, 친구 이유 사람, 영어, 일본 언어, 한 국 언어는 음악 감사, Nian 병약한 달력, 영국 살롱, 무역 시장, 정보, 원거리 통신 전자, 전기기구, 통화 외국 교환, 뉴 스, 책, 이야기의옆에,fable 의 요전같은 총계, 소설, 밑그림 철학, 철학은, 동포 공부한다, 시, 낱말, 산문, 곡, 처리한다 독창성, 소프트웨어 기술, 소리, 그림,심상 자료 창고 , C++, C.NET 의 웨브, 자바, J2EE XML, HTML 의 건강, 여행, 일생안에 지키는 소프트웨어 기술설계, 생리를">
25 <link rel="stylesheet" href="css/style.css" type="text/css">
26 <link rel="stylesheet" href="css/shadow.css" type="text/css">
27<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
28<link rel="icon" href="favicon.ico" type="image/ico" />
29<link rel="Bookmark" href="favicon.ico">
30 <link rel="home" title="Home" href="http://www.dusystem.com" />
31<title>cdo send mail</title>
32</head>
33
34<body>
35<%
36'-----------------第一步 创建对象-------------
37Dim oMsg
38Set oMsg = Server.CreateObject("CDO.Message")
39'-----------------第二步 进行设置-------------
40oMsg.From = "geovindu@dupcit.com" '设置发信人的邮箱
41oMsg.To = "geovindu@gmail.com" '设置收信人的邮箱
42oMsg.Subject = "这是邮件标题CDO發郵件測試"
43'抄送,你可以发任意数量
44oMsg.CC = """geovindu-1"" <ginhongzhao@163.com>, ""geovindu-2"" <geovindu@126.com>"
45'密件抄送,也可以发任意数量
46oMsg.BCC = """geovindu-1"" <ginhongzhao@gmail.com>, ""geovindu-2"" <geovindu@163.com>"
47
48
49Dim strHTML
50strHTML = "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">"
51strHTML = strHTML & "<html xmlns=""http://www.w3.org/1999/xhtml"">"
52strHTML = strHTML & " <head>"
53strHTML = strHTML & " <title>嵌入图片和其它文件</title>"
54strHTML = strHTML & " </head>"
55strHTML = strHTML & " <body><p>"
56strHTML = strHTML & " <img src=""cid:previous.png""></p><p>嵌入一幅图片</p><a href=http://www.w3.org/WAI/WCAG1AA-Conformance target=_blank>geovindu</a>"
57strHTML = strHTML & " </body>"
58strHTML = strHTML & "</html>"
59'设置信件内容是HTML格式
60oMsg.HTMLBody = strHTML
61'将多媒体文件添加进邮件内容内,并定义一个内容ID为previous.png
62'HTML使用该ID来引用邮件内容中的多媒体文件
63oMsg.AddRelatedBodyPart "C:\Documents and Settings\geovindu\My Documents\My Pictures\previous.png", "previous.png", cdoRefTypeId
64'oMsg.TextBody = "这是邮件正文,可以多写一点!!!"
65'-----------------第三步 远程配置-------------
66Dim oConfig,strNameSpace
67Set oConfig = Server.CreateObject("CDO.Configuration")
68strNameSpace = "http://schemas.microsoft.com/cdo/configuration/"
69oConfig.Fields(strNameSpace & "smtpserver") = "mail.dupcit.com"
70oConfig.Fields(strNameSpace & "smtpserverport") = 25
71oConfig.Fields(strNameSpace & "smtpaccountname") = "geovindu@dupcit"
72'注意下面的配置应该与oMsg.From相同
73oConfig.Fields(strNameSpace & "sendemailaddress") = "geovindu@dupcit.com"
74oConfig.Fields(strNameSpace & "smtpauthenticate") = 1
75oConfig.Fields(strNameSpace & "sendusername") = "geovindu@dupcit.com"
76oConfig.Fields(strNameSpace & "sendpassword") = "password"
77oConfig.Fields(strNameSpace & "Smtpusessl") = False
78oConfig.Fields(strNameSpace & "sendusing") = 2
79oConfig.Fields.Update() '使配置生效
80Set oMsg.Configuration = oConfig '赋给oMsg.Configuration属性
81'-----------------第四步 执行发送-------------
82oMsg.Send()
83Set oMsg = Nothing '发送成功后释放对象
84Response.Write("成功发送邮件!!!")
85%>
86
87</body>
88
89</html>
90
哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)