波仔

信息蕴藏价值
随笔 - 59, 评论 - 433, 引用 - 5

导航

关于

    I am building a portal named Starlight which are based on the Teamwork Portal(a portal I have finished, because of the name has been registered by another company I have changed the name) and DynamiceWeb.
    You can get the latest information about it here.


每月存档

最新留言

  • re:BI数据级权限解决方案
    <p>hi,你好。这个BI数据权限,很有新意。有个细节问题,想向你请教,</p> <div>StrtoSet(BI.DataSecurity.GetDimensio...
    by shenzhenjia(注册) on 2009/6/14 17:09:43
  • re:BI数据级权限解决方案
    <p>hi,你好。这个BI数据权限,很有新意。有个细节问题,想向你请教,</p> <div>StrtoSet(BI.DataSecurity.GetDimensio...
    by shenzhenjia(注册) on 2009/6/14 17:09:17
  • re: BI数据级权限解决方案
    不错,另外字符串相加建议采用StringBuilder做处理。
    by kentliu(匿名) on 2008/8/18 9:44:31
  • re: 发布一个博客软件系统——肥猫博客
    谢谢.fmblog还在不断完善中,你说的很多确实是我们需要改进的。
    by jasper(匿名) on 2008/4/24 14:38:01
  • 日啊,你这个是asp.net版么?
    你有试验过么?就在这里乱讲,你这样绝对会碰到权限cdo.message问题,最恶心的这种沽名钓誉的
    by passer(匿名) on 2007/12/10 10:07:00
  • 回复: I have a dream
    I think my dream is very simple .I just want find a good job .by the end of the fouth college year.
    by kally(匿名) on 2007/11/14 21:56:00
  • 回复: I have a dream
    I have a dream that one day every people can live on the earth with out WAR
    by w4er(匿名) on 2007/11/3 13:53:00
  • 回复: I have a dream
    no thing is diffcult
    by w4er(匿名) on 2007/11/3 13:47:00
  • 回复: 发布一个博客软件系统——肥猫博客
    肥猫博客的确是个很不错博客软件系统,但很遗憾目前还不是很适合使用,我有用过你的博客,后台操作感一流,功能的确很好,但性能不是很稳定,网站皮肤只有一个,博客皮肤稍放点大的东西上去会扭曲整个页面,看起不不...
    by 赶路人(匿名) on 2007/10/22 10:27:00
  • 回复: 比DotNetNuke更好的Portal
    有谁用过 lightPortal 吗?一个功能强大的java 开源 portal
    by jacky(匿名) on 2007/9/21 9:10:00
  • 回复: ASP.NET发送邮件
    有ASP版的吗?
    by 开心网(匿名) on 2007/8/23 16:11:00
  • 回复: ASP.NET发送邮件
    有ASP版的吗? 有的话不错
    by 开心网(匿名) on 2007/8/23 16:11:00

  • 我 <br>地联 系电话好像是13651765786,号179447907
    by 王竟华(匿名) on 2007/8/8 15:19:00
  • 回复: I have a dream
    i have a dream <br>that is i will happiness all my life
    by Joy(匿名) on 2007/6/28 17:58:00
  • 回复: I have a dream
    I have a dream that i can do anything.
    by aaronnorman(匿名) on 2007/6/17 11:09:00

广告

ASP.NET发送邮件

由于需要在Starlight Portal中提供邮件发送功能,所以在网上找了一些asp.net中发送邮件的文章,可是都不能满足需求。因为大部分的文章都介绍得很简单,只是告诉你怎么用MailMessage,而我想用Gmail的邮箱发送信件,因此会碰到一些额外的问题,比如:

  1. Gmail的Smtp端口不是默认的25,而是465
  2. Gmail的Smtp采用的是SSL连接

因此,要发送邮件,就必须解决这两个问题,其他的基本问题都可以很容易的找到解决方法。在这里记下代码,以供大家使用。

    MailMessage msg = new MailMessage();

    msg.From = settings.SystemEmailAccount;
    msg.To = to;
    msg.Subject = subject;
    msg.Body = body;

    if(settings.SmtpAuthenticationRequired)
    {
     msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1" );
     msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", settings.SystemEmailAccount);
     msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", settings.SystemEmailAccountPassword);
    }

    if(settings.SmtpPort != 25)
    {
     msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", settings.SmtpPort.ToString());
    }

    if(settings.SmtpUseSSL)
    {
     msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "1");
    }

    SmtpMail.SmtpServer = settings.SmtpServer;
    SmtpMail.Send(msg);

 BTW:到今天为止,Starlight Portal已经有了更新、更好的版本,欢迎大家参观参观。

posted on 2005-08-31 13:07:00 by jasper  评论(12) 阅读(10996)

Powered by: Joycode.MVC引擎 0.5.2.0