【TKMP】保存したメールからの複数添付ファイル保存について |
- 日時: 2015/10/23 11:36
- 名前: こくぶ
- 利用中意図した処理を行えなかった箇所があったため報告致します。
フォルダに保存した添付ファイルが複数あるメールをSystem.IO.FileStreamクラスで読み取り、 FileCollectionで添付ファイルを取得しようとすると、添付ファイルが1件しか取得できませんでした。 処理は以下のように行っておりました。
サーバへの接続用クラスを作成 TKMP.Net.PopClient pop = new TKMP.Net.PopClient(logon, address, port);
取得したメールを保存 for (int cnt = 0; cnt < pop.MailDatas.Length; cnt++) { TKMP.Net.MailData data = pop.MailDatas[cnt]; byte[] source = new byte[data.Length]; data.ReadBody(); data.DataStream.Read(source, 0, source.Length); System.IO.File.WriteAllBytes(fileName, source);
}
添付ファイル保存 FileStream fs = new FileStream(fileName, FileMode.Open); TKMP.Reader.MailReader reader = new TKMP.Reader.MailReader(fs, false);
foreach(TKMP.Reader.File file in reader.FileCollection) { file.FileSave(保存先); }
|
|