<% @Language=vbscript %>
<%
option explicit
dim objMail
Set objMail = Server.CreateObject("CDONTS.NewMail")objMail.From ="[email protected]"
objMail.To = "[email protected]"
objMail.Subject ="测试"
objMail.body = "请看附件"
objMail.attachurl server.mappath("zm.gif")objMail.Send
Set objMail = Nothing
response.write "邮件发送成功"
%>
<%
option explicit
dim objMail
Set objMail = Server.CreateObject("CDONTS.NewMail")objMail.From ="[email protected]"
objMail.To = "[email protected]"
objMail.Subject ="测试"
objMail.body = "请看附件"
objMail.attachurl server.mappath("zm.gif")objMail.Send
Set objMail = Nothing
response.write "邮件发送成功"
%>
解决方案 »
- 网站分享代码~ 一个页面可以放置多组,且每组分享的内容不同
- 微博的个性域名是HttpHandler实现的吗?
- 怎么解决ASP.NET运行错误:allowDefinition='MachineToApplication'错误?
- rewrite 具体用法
- 小问题就是不会
- [在线] Response.Write(...alert('')....) 后接 Response.Redirect, 如何让前者起作用?
- 介绍给大家一个数据库技术网站
- iframe
- 为什么我做的网络上传和下载程序在有的机器上可以用,在有的机器上又不好用?
- 如何将SQL查询出来的数据放在一个强类型DataSet的一个表里如(ds.Table1)
- 在win2kS上无法获取win2kS域服务器上VSS中的项目???
- 这是个傻问题,但有高分!
Sending Email with ASP.NET
http://www.aspheute.com/english/20000918.aspSend an HTML E-Mail with Attachment through SMTP Server
http://www.dotnetextreme.com/code/htmlmail.asp
http://www.dotnetextreme.com/code/htmlmail.aspusing System;
using System.Web.Mail;class HTMLMail
{
public static void Main()
{
Console.WriteLine("Sending Mail");
try
{
MailMessage oMail = new MailMessage();
Console.WriteLine("Mail Created");
oMail.To = "[email protected]";
oMail.Cc = "[email protected]";
oMail.From = "[email protected]";
oMail.Subject = "Hi Yateen";
oMail.BodyFormat = MailFormat.Html;
string strBody = "<b>Hello <i>Yateen</i></b>" +
" This is from <font color=red>.NET</font>";
oMail.Body = strBody;
SmtpMail.Send(oMail);
Console.WriteLine("Mail Sent");
}
catch(Exception ex)
{
Console.WriteLine("Error : " + ex.Message);
}
}
}
We create a Mail object and set the appropriate mail properties like To, From,CC, Subject, Body and then set the BodyFormat property of the mail object to HTML.Let's see how do we add an attachment to the above mail. Add the command given below just before we send the mail with the statement Smtp.Send .oMail.Attachments.Add(new MailAttachment("c:\\aishwarya1.jpg"));We need to add "\" twice since it is an escape character.Compile the above code using the following commandcsc /r:System.Web.dll HTMLMail.csYou can run the console.exe from command prompt to send the mail. Happy Coding !!!!
这里只是简单地调用system.web的MailMessage()类,但是此类并不适用现在普遍存在的要求验证的SMTP服务器
Addheres RFC 821/1521/2554/2821 compliance.
Features:
html/text messages, multiple recipients, multiple attachments, multiple servers, connection retries, MIME encoding, custom headers, message priority,
authentication, message serialization/deserialization, supports all character sets and more!
Includes it's source code.
UPDATE: All reported && known bugs have been fixed. Sample Type: CLR
.NET Version: 1.0
Experience Level: Advanced
Dependencies: