Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 网站建设 > 服务器相关 > c#实现自动发邮件
【标  题】:c#实现自动发邮件
【关键字】:c#
【来  源】:http://www.cublog.cn/u/14454/showart.php?id=254556

c#实现自动发邮件

Your Ad Here
c#实现发mail
public void send(MailMsg msg, string[] attachments)
    {
        putlog("send:1");
        MailMessage mail = new MailMessage();
        mail.To = msg.MailTo;
        mail.From = msg.MailFrom;
        mail.Subject = msg.MailSubject;
        mail.Body = msg.MailContent;
        mail.BodyFormat = MailFormat.Html;
        for (int i = 0; i < attachments.Length; i++)
        {
            putlog("send:1-" + (i + 1).ToString());
            if (attachments[i] != null && attachments[i].ToString() != "")
            {
                putlog("send:1-" + (i + 1).ToString() + "-1");
                MailAttachment attachment = new MailAttachment(attachments[i].ToString());
                mail.Attachments.Add(attachment);
            }
        }
        putlog("send:2");
        //basic authentication
        mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
        //set your username here
        mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", ConfigurationManager.AppSettings["UserName"]);
        //set your password here
        mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", ConfigurationManager.AppSettings["UserPwd"]);
        //ip of mail server
        SmtpMail.SmtpServer = ConfigurationManager.AppSettings["mailServerIP"]; //"10.25.100.21";  //your real server goes here
        SmtpMail.Send(mail);
    }
.net 实现服务器文档在线修改:【上一篇】
手机病毒:【下一篇】
【相关文章】
  • c#实现根据服务器上已存在的文档模板创建文件
  • c#实现日志
  • 蜘蛛/爬虫程序的多线程控制(C#语言)
  • C#学习:构造、析构函数
  • 花样贝塞尔曲线(C#)
  • 直接调用内置数据源连接对话框(C#/VB.NET2005源码)
  • “C#高级编程学习“ 内存:引用和值变量
  • C#与面向对象编程语言——《C#编程极限》第二章
  • 公司内部制定C#编程命名规范,大家帮忙修改一下
  • mysql存储过程及c#调用标准版
  • 【随机文章】
  • Flash文字特效系列教程:扫描文字
  • 汽配巨头变形记
  • TC写的“泡泡堂”(1)
  • 四种方法实现VC枚举系统当前进程
  • C#中"is" vs "as"
  • Painter 界面定制(3)
  • “制作网页”建议数点
  • 开发工具大比拚之Visual C++ vs. Delphi(一)
  • 敏捷软件开发 读书笔记 (2)——OO五大原则(1.SRP 单一职责原则)
  • 关于Flash+HTML实用技巧的一点补充
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.