2011-06-08 67 views
0

我正在使用郵件類將附件作爲圖像發送給多個收件人。 但問題是電子郵件發送給它拋出的是「形象正在被另一個進程使用」 ..這可怎麼解決的例外第一接收者..用圖像附件發送多個郵件

我得到用戶列表項爲:

foreach (ListItem item in lstboxlist.Items) 
       { 
        to = Convert.ToString(item); 
        select_theme_tosend(to, sub); 
       } 

,我作爲郵件發送給用戶:

string source_theme = theme; 
      string dest_theme_path = "xxx"; 

      if (File.Exists(dest_theme_path)) 
      { 
       File.Delete(dest_theme_path); 
      } 
      File.Copy(source_theme, dest_theme_path); 
      xmlDoc.Load(theme); 
      XmlNode node = null; 
      SendMail_Html send_html = new SendMail_Html(); 

       MailMessage mail = new MailMessage(); 
       Attachment footer_att = null; 
       Attachment header_att = null; 
       Attachment other_att = null; 
       mail.Attachments.Add(other_att); 
       } 
       xmlDoc.Save(theme); 

       StreamReader strm_rdr = new StreamReader(theme); 
       string theme_text = strm_rdr.ReadToEnd(); 

       SendMail send_mail = new SendMail(); 
       send_html.sent_htmlmail1(to, theme_text, subject, footer_att, header_att, other_att); 
       mail.Dispose(); 
       // File.Delete(header_path); 
       // File.Delete(other_imagepath); 
       // File.Delete(foot_image_path); 
} 

如果我取消它顯示作爲電子郵件發送至第二地址錯誤最後一行: 「指定的文件無法找到」 ... 怎麼樣d我做發送多封電子郵件...... 請幫助...

回答

1

關閉流你用它完成之後,因此,例如:

StreamReader strm_rdr = new StreamReader(theme); 
string theme_text = strm_rdr.ReadToEnd(); 
strm_rdr.Close();