如何使用 Cdosys.dll 库使用ASP发送邮件带附件

 <%@ Language=VBScript CODEPAGE=65001%>
<% Response.Buffer=True %>
<%
'Collaboration Data Objects, version 1.2.1(CDO)
'http://www.microsoft.com/downloads/details.aspx?FamilyId=2714320D-C997-4DE1-986F-24F081725D36&displaylang=en
'-----------------第一步    创建对象 cdosys.dll  cdoex.dll-------------
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta content="Geovin Du" name="Author">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>™Du Computer information Technology Co,.Ltd® is engaged in applied software design, development and
service.We provide system solution to fund flow, information flow, human
resource flow, material flow and control flow.勝利は仕事部屋である貴方にご光来を賜ることを歓迎,®geoVI 일
방,고향 geocVi 스튜디오는 缔友计算机信息技术有限公司,Du Computer information Technology Co,.Ltd.Geovin Du.</title>
<!--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。

<META HTTP-EQUIV="REFRESH" CONTENT="11; URL=http://www.dusytem.com/index.htm"> 2006-03-12 designer Geovin Du-->
<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。.">
<meta name="description" content="Study,Communicate。 ">
<meta name="Robots" content="all index follow ">
<meta name="Author" content="涂聚文" />
<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 일 방 &#8482;고향 geocVi 스튜디오는 geovindu, 중국 의  Guangdong 지방, Shenzhen 의 NanShan 지역, 높은 새로운 기술 적인 공업 발달 지역, 원래 affiliation, Jiangxi 지방 , Ji'an 도시, coutry  YongFeng, Ouyang's에, 너를 환 영한다.  면담 공개토론, 친구 이유 사람, 영어, 일본 언어, 한 국 언어는...  음악 감사, Nian 병약한 달력, 영국 살롱, 무역  시장, 정보, 원거리 통신 전자, 전기기구, 통화 외국 교환, 뉴 스, 책, 이야기의옆에,fable 의 요전같은 총계, 소설, 밑그림  철학,  철학은, 동포 공부한다, 시, 낱말, 산문, 곡,  처리한다  독창성, 소프트웨어 기술, 소리, 그림,심상 자료 창고 , C++, C.NET 의 웨브, 자바, J2EE  XML, HTML 의 건강, 여행,  일생안에 지키는 소프트웨어 기술설계, 생리를">
        <link rel="stylesheet" href="css/style.css" type="text/css">
        <link rel="stylesheet" href="css/shadow.css" type="text/css">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="icon" href="favicon.ico" type="image/ico" />
<link rel="Bookmark" href="favicon.ico">
        <link rel="home" title="Home" href="http://www.dusystem.com" />
<title>cdo send mail</title>
</head>

<body>
<%
'-----------------第一步    创建对象-------------
Dim oMsg
Set oMsg = Server.CreateObject("CDO.Message")
'-----------------第二步    进行设置-------------
oMsg.From = "geovindu@dupcit.com"        '设置发信人的邮箱
oMsg.To = "geovindu@gmail.com"     '设置收信人的邮箱
oMsg.Subject = "这是邮件标题CDO發郵件測試"
'抄送,你可以发任意数量
oMsg.CC = """geovindu-1"" <ginhongzhao@163.com>, ""geovindu-2"" <geovindu@126.com>"
'密件抄送,也可以发任意数量
oMsg.BCC = """geovindu-1"" <ginhongzhao@gmail.com>, ""geovindu-2"" <geovindu@163.com>"


Dim strHTML
strHTML = "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">"
strHTML = strHTML & "<html xmlns=""http://www.w3.org/1999/xhtml"">"
strHTML = strHTML & "  <head>"
strHTML = strHTML & "    <title>嵌入图片和其它文件</title>"
strHTML = strHTML & "  </head>"
strHTML = strHTML & "  <body><p>"
strHTML = strHTML & "   <img src=""cid:previous.png""></p><p>嵌入一幅图片</p><a href=http://www.w3.org/WAI/WCAG1AA-Conformance target=_blank>geovindu</a>"
strHTML = strHTML & "  </body>"
strHTML = strHTML & "</html>"
'设置信件内容是HTML格式
oMsg.HTMLBody = strHTML
'将多媒体文件添加进邮件内容内,并定义一个内容ID为previous.png
'HTML使用该ID来引用邮件内容中的多媒体文件
oMsg.AddRelatedBodyPart "C:/Documents and Settings/geovindu/My Documents/My Pictures/previous.png", "previous.png", cdoRefTypeId
'oMsg.TextBody = "这是邮件正文,可以多写一点!!!"
'-----------------第三步    远程配置-------------
Dim oConfig,strNameSpace
Set oConfig = Server.CreateObject("CDO.Configuration")
strNameSpace = "http://schemas.microsoft.com/cdo/configuration/"
oConfig.Fields(strNameSpace & "smtpserver") = "mail.dupcit.com"
oConfig.Fields(strNameSpace & "smtpserverport") = 25
oConfig.Fields(strNameSpace & "smtpaccountname") = "geovindu@dupcit"
'注意下面的配置应该与oMsg.From相同
oConfig.Fields(strNameSpace & "sendemailaddress") = "geovindu@dupcit.com"
oConfig.Fields(strNameSpace & "smtpauthenticate") = 1
oConfig.Fields(strNameSpace & "sendusername") = "geovindu@dupcit.com"
oConfig.Fields(strNameSpace & "sendpassword") = "password"
oConfig.Fields(strNameSpace & "Smtpusessl") = False
oConfig.Fields(strNameSpace & "sendusing") = 2
oConfig.Fields.Update()                        '使配置生效
Set oMsg.Configuration = oConfig             '赋给oMsg.Configuration属性
'-----------------第四步    执行发送-------------
oMsg.Send()
Set oMsg = Nothing     '发送成功后释放对象
Response.Write("成功发送邮件!!!")
%>

</body>

</html>

上一篇:如何使用 Cdosys.dll 库使用 Visual C# 中发送电子邮件带有附件接收邮件


下一篇:C#2.0 数字“0”是有一道斜线,打印虚线,Pos打印