ToEmail

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                MailMessage m = new MailMessage();
                m.From = new MailAddress("@126.com");
                m.To.Add(new MailAddress("@Gmail.com"));
                m.Attachments.Add(new Attachment(@"F:\Img261598108.jpg"));

                m.Attachments[0].ContentId = "KSpring";
                m.Attachments[0].ContentDisposition.Inline = true;
                m.Attachments[0].NameEncoding = m.SubjectEncoding = m.BodyEncoding = Encoding.UTF8;
                m.Subject = "555555555555";
                m.IsBodyHtml = true;
                m.Body = string.Format(@"<img=""{0}""/><a herf=""{0}"" target=""_black"">fsdf</a>", "cid:" + m.Attachments[0].ContentId);
                SmtpClient s = new SmtpClient();
                s.Port = 25;
                s.Host = "smtp.126.com";
                s.Credentials = new System.Net.NetworkCredential("1111111", "111111111");
                s.Send(m);
                Console.WriteLine("is successs");
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message.ToString());
                Console.ReadLine();
            }

        }
    }
}

posted @ 2009-05-11 09:33  QSpring  阅读(232)  评论(0编辑  收藏  举报