日期:2014-05-18  浏览次数:21089 次

c# winform,我写了个发送email的小程序,但是每次做完send之后,它不发,要关闭程序后才发,怎么回事?
如题:

我的代码:
                        string   server   =   "aaa.bb.ccc ";
                        string   htmlBody   =   " <b> Embedded   image   file. </b> <DIV> &nbsp; </DIV> ";

                        htmlBody   +=   @ " <img   alt= " " " "   hspace=0   src= " "cid:112233 " "   align=baseline   border=0   > ";
                        htmlBody   +=   " <DIV> &nbsp; </DIV> <b> This   is   the   end   of   Mail... </b> ";
                        try
                        {
                                AlternateView   htmlView   =   AlternateView.CreateAlternateViewFromString(htmlBody,   null,   "text/html ");

                                MailMessage   message   =   new   MailMessage( "aaa@bbb.com ",   "ccc@bbb.com ");
                                message.Subject   =   "5 ";

                                LinkedResource   imageView   =   new   LinkedResource( "c:\\pix\\a.jpg ",   "image/jpeg ");
                                imageView.ContentId   =   "112233 ";
                                imageView.TransferEncoding   =   TransferEncoding.Base64;
                                htmlView.LinkedResources.Add(imageView);

                                message.AlternateViews.Add(AlternateView.CreateAlternateViewFromString( "plain   text ",   null,   "text/plain "));
                                message.AlternateViews.Add(htmlView);

                                //Send   the   message.
                                SmtpClient   client   =   new   SmtpClient(server);
                                //   Add   credentials   if   the   SMTP   server   requires   them.
&nbs