日期:2014-05-20  浏览次数:21171 次

大虾 我想问一个问题 怎么用ASP自动发送邮件
我想做个网页   在上面点击审核按钮  
会自动发送一个邮件给某个的人!怎么实现这个呢?


------解决方案--------------------
邮件要有相应的接口吧

------解决方案--------------------
?
http://blog.joycode.com/ghj/archive/2005/10/01/64458.aspx

http://www.aspxboy.com/490/default.aspx
------解决方案--------------------
去看看System.Web.Mail 包的SmtpMail
这是MSDN的例子

using System;
using System.Web.Mail;

namespace SendMail
{
class usage
{
public void DisplayUsage()
{
Console.WriteLine( "Usage SendMail.exe <to> <from> <subject> <body> ");
Console.WriteLine( " <to> the addresses of the email recipients ");
Console.WriteLine( " <from> your email address ");
Console.WriteLine( " <subject> subject of your email ");
Console.WriteLine( " <body> the text of the email ");
Console.WriteLine( "Example: ");
Console.WriteLine( "SendMail.exe SomeOne@Contoso.com;SomeOther@Contoso.com Me@contoso.com Hi hello ");
}
}


class Start
{
// The main entry point for the application.
[STAThread]
static void Main(string[] args)
{
try
{
try
{
MailMessage Message = new MailMessage();
Message.To = args[0];
Message.From = args[1];
Message.Subject = args[2];
Message.Body = args[3];

try
{
SmtpMail.SmtpServer = "your mail server name goes here ";
SmtpMail.Send(Message);
}
catch(System.Web.HttpException ehttp)
{
Console.WriteLine( "{0} ", ehttp.Message);
Console.WriteLine( "Here is the full error message output ");
Console.Write( "{0} ", ehttp.ToString());
}
}
catch(IndexOutOfRangeException)
{
usage use = new usage();
use.DisplayUsage();
}
}
catch(System.Exception e)
{
Console.WriteLine( "Unknown Exception occurred {0} ", e.Message);
Console.WriteLine( "Here is the Full Message output ");
Console.WriteLine( "{0} ", e.ToString());
}
}
}
}

------解决方案--------------------
学习来了
------解决方案--------------------
using System;
using System.Web.Mail;

namespace LiveMessage.Common
{
/// <summary>
/// SendMail 的摘要说明。
/// </summary>
public class SendMail
{
public SendMail()
{
//
// TODO: 在此处添加构造函数逻辑
//
}

public static bool sendMail(string from,string to,string subject,string body,string smtpaccountname,string sendusername,string sendpassword,string smtpServer)
{
try
{
MailMessage mm=new MailMessage();
mm.BodyFormat=MailFormat.Html;
mm.From=from;
mm.To=to;