使用System.Web.Mail通过需验证的邮件服务器发送邮件

web|发送邮件|服务器|邮件服务器

使用System.Web.Mail通过需验证的邮件服务器发送邮件

使用System.Web.Mail通过需验证的邮件服务器发送邮件,下面是Scott Water在dotText中写的一个发邮件的类,使用起来比较方便,整个类的代码如下:

using System;

using System.Web.Mail;

namespace ZZ

{

///

/// SystemMail 的摘要说明。

///

public class SystemMail

{

private string _adminEmail;

private string _smtpServer = "localhost";

private string _password;

private string _userName;

public SystemMail()

{

}

public string AdminEmail

{

get{return _adminEmail;}

set{_adminEmail = value;}

}

public string SmtpServer

{

get{return _smtpServer;}

set{_smtpServer = value;}

}

public string Password

{

get{return _password;}

set{_password = value;}

}

public string UserName

{

get{return _userName;}

set{_userName = value;}

}

public bool Send(string to, string from, string subject, string message)

{

try

{

MailMessage em = new MailMessage();

em.To = to;

em.From = from;

em.Subject = subject;

em.Body = message;

//Found out how to send authenticated email via System.Web.Mail at http://SystemWebMail.com (fact 3.8)

if(this.UserName != null && this.Password != null)

{

em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication

em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", this.UserName); //set your username here

em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", this.Password); //set your password here

}

SmtpMail.SmtpServer = this.SmtpServer;

SmtpMail.Send(em);

return true;

}

catch

{

return false;

}

}

}

}

需要更多信息可以查看http://SystemWebMail.com

时间: 2024-09-17 04:06:43

使用System.Web.Mail通过需验证的邮件服务器发送邮件的相关文章

通过System.Web.Mail程序发邮件

web|程序|发邮件 在.net 1.1里面,如何用程序控制来发送电子邮件.比如,网站用户注册成功后,给注册用户自动发一封邮件,提示用户的注册信息.再则,有时候需要每天定时的把一个报表发给固定的几个人.综合起来需要解决如下的几个问题: 1.SMTP服务器身份认证. 2.收件人为多人时,怎么发送. 3.发送邮件附件. 实现程序如下: 为了使用System.Web.Mail,在名字空间里引用: using System.Web.Mail; 定义一个发送邮件的过程         /**//// <s

在.NET 应用程序中用System.Web.Mail 发送电子邮件

web|程序 在.NET 应用程序中用System.Web.Mail 发送电子邮件 作者:Mark Strawmyer日期:February 9, 2004 -------------------------------------------------------------------------------- 欢迎来到 .NET Nuts & Bolts 栏目.在这个栏目中,我们将探讨怎样在应用中发送电子邮件.这将用到System.Web.Mail 名字空间中的类. 协作数据对象Wind

在Web上利用System.Web.Mail发送EMail

web 这是个vb.net的例子~ Email.aspx <%@ Page Language="vb" AutoEventWireup="false" Codebehind="Email.aspx.vb" Inherits="asif.SendEmail"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">&

用System.Web.Mail发送电子邮件

web 作者:Mark Strawmyer 日期:February 9, 2004   欢迎来到 .NET Nuts & Bolts 栏目.在这个栏目中,我们将探讨怎样在应用中发送电子邮件.这将用到System.Web.Mail 名字空间中的类. 协作数据对象Windows 2000 协作数据对象 (CDOSYS) 是微软用来创建和发送基于标准的电子邮件信息的消息组件.它是 用与 Windows NT的协作数据对象(CDONTS) 的替代物. 尽管由于向后兼容的原因 CDONTS 已包含在 Wi

using System.Web.Mail to send email

there are many demos for send a email with c sharp language .however,you will find that most of them will be failed because of SMTPServer.Especially,authorization is required.   public void SendEMail()        ...{            MailMessage mail = new Ma

ASP.net发邮件的例程WEB MAIL

asp.net|web|发邮件 ASP.net发邮件的例程(Language:"C#"; 带EMail地址验证) -------------------------------------------------------------------------------- <%@ page Language = "C#" debug = "true" Explicit="True" %> <%@ Impor

asp.net System.Net.Mail发送邮件问题,

问题描述 下面是代码...............可是.发送出错.错误如下:=============================错误信息开始======================================="/SimpleMail"应用程序中的服务器错误.--------------------------------------------------------------------------------邮箱不可用.服务器响应为:Óû§±»Ëø¶¨说明:执行

c# web.mail发送附件问题

问题描述 程序生成一个pdf文件,文件正常打开,有内容,发送邮件时取这个文件做为附件,成功发送后收到的邮件中pdf内容却为空.只有txt文件作为附件发送后,接收是正常的,其它类型文件发送后,接收到的文件都是错误的,这是什么原因,请大家帮忙 解决方案 解决方案二:发送时候编码格式有没有指定?解决方案三:附件大小有没有考虑?解决方案四:参考MSDN吧解决方案五:除了txt文本可以,其它类型的附件都被损坏了,是为什么?急呀解决方案六:System.Web.Mail.MailMessagenewMsg=

一个通过web.Mail发送邮件的类

  using System;using System.Web;using System.Web.Mail;using Dottext.Framework;using Dottext.Framework.Configuration;namespace YourNamespace.Email{ /// <summary> /// Default implementation of the IMailProvider /// </summary> public class System