メールを受信しhmailserver
、それらのメールを別のレポート メールの添付ファイルとして.emlファイルとして送信しています。
これらのメールを添付ファイルとして読んだり送信したりする際に問題が発生しています。
これが私がやっていることです。
public void addAttachment(string pathname, bool retry)
{
string attachmentname = "";
do
{
try
{
attachmentname = Path.GetFileNameWithoutExtension(pathname);
Stream file = new MemoryStream(File.ReadAllBytes(pathname));
Log.WriteMessage("Size" + file.Length);
dtstreamAttach.Add(attachmentname+".eml", file);
retry = false;
}
catch (ArgumentException e)
{
string strCurrentTs = DateTime.Now.ToString(strDateFormat);
attachmentname = attachmentname + "-" + strCurrentTs+".eml";
}
} while (retry);
}
それで、
MailMessage message = new MailMessage();
.
.
message.Attachments.Add(new Attachment(kvp.Value, kvp.Key)); // I have an attachment dictionary
string contenttype = GetMimeType(".eml");
ContentType cnttype = new ContentType(contenttype);
message.Attachments[0].ContentType = cnttype;
ご覧のとおり、ストリーム サイズを出力します。これは4790バイト (4KB)のように出力され ます。
ファイル パスを確認し、レポート メールが送信されるまでメールが存在することも確認しました。また、コンテンツ タイプが であることも確認しmessage/rfc822
ました。
すべてがチェックアウトされているようです。問題が何であるかわかりません。