//为每一个 EmailinfoInfo 分配线程
foreach (EmailinfoInfo info in list)
{
handleGroup.QueueWorkItem(DataThreadHandle, sendConfigInfo, WorkItemPriority.BelowNormal);
}
//线程处理的事情
protected virtual void DataThreadHandle(MailSendConfigInfo info)
{
sended = helper.Send();
}
public bool Send()
{
Mail_Message m = Create_PlainText_Html_Attachment_Image(toList, ccList, bccList, unifiedReplyTo, unifiedDisplayName, subject, body, attachments, notifyEmail, plaintTextTips);
using (MemoryStream stream = new MemoryStream())
{
m.ToStream(stream, new MIME_Encoding_EncodedWord(MIME_EncodedWordEncoding.Q, Encoding.UTF8), Encoding.UTF8);
stream.Position = 0;
client.SendMessage(stream);
sended = true;
}
}
每封邮件大小在20M左右 同时间大概有40~80封 一开始能正常运行 但是时间久了就会报错
System.OutOfMemoryException 为什么??!!!
问题可能出现在 m.ToStream() 的实现代码中
能详细的说一下嘛?
@xuliyuan173: 在.ToStream中是如何将内容复制到MemoryStream中的?
@dudu:
//
// 摘要:
// Store MIME enity to the specified stream.
//
// 参数:
// stream:
// Stream where to store MIME entity. Storing starts form stream current position.
//
// headerWordEncoder:
// Header 8-bit words ecnoder. Value null means that words are not encoded.
//
// headerParmetersCharset:
// Charset to use to encode 8-bit header parameters. Value null means parameters
// not encoded.
//
// 异常:
// System.ArgumentNullException:
// Is raised when stream is null.
public void ToStream(Stream stream, MIME_Encoding_EncodedWord headerWordEncoder, Encoding headerParmetersCharset);
这个是lumisoft封装的方法