send mail

1、使用SMTP

参考URL: http://blog.csdn.net/johnsuna/archive/2008/04/05/2253777.aspx

     // 设置发信人的EMAIL地址
        message.From = new MailAddress(fromAddress);

        // 设置收信人的EMAIL地址
        message.To.Add(toAddress);
        // 设置回复的EMAIL地址
        //message.ReplyTo = new MailAddress(replyTo Address);

        // 设置抄送的EMAIL地址
        // message.CC.Add(ccAddress);
        // message.Bcc.Add(bccAddress);

        // 设置发信主题及内容        
        message.Subject = msgSubject;
        message.Body = body;
        message.IsBodyHtml = isHtmlBody;
        // 设置SMTP host及端口
        client.Host = "smtp.gmail.com";
        client.Port = 25;
        client.UseDefaultCredentials = true;       
        client.Send(message);

2、使用OutLook

  参考URL:  http://topic.csdn.net/u/20090317/15/0bbd0e71-378d-4b00-8f61-f8c2ffc91263.html 
        Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application();
        NameSpace ns = app.GetNamespace("mapi");
        ns.Logon("UserName", "password",false, true);
        MailItem message = (MailItem)app.CreateItem(OlItemType.olMailItem);
        message.To = "mailAddress";
        message.Subject =Subject;
        message.Body = msg;
        message.Send();
        ns.Logoff();  

3、mail端口测试

  参考URL: http://mail.google.com/support/bin/answer.py?answer=86376#

  Telnet pop.gmail.com 995

4、其他参考:

  http://www.cnblogs.com/chencaixia/archive/2009/02/23/1258296.html

  http://www.cnblogs.com/dlutwy/archive/2009/03/31/1425747.html

 

posted @ 2009-04-02 17:42  玛雅人  阅读(518)  评论(0编辑  收藏  举报