本文介绍了使用简单的MAPI(MAPI32)读取.msg/.eml附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在将电子邮件附件读取为.msg或.eml扩展名时遇到问题,它无法保存在磁盘上,或者在调试模式下在附件[]中显示时也显示null.您能帮助/解决问题还是建议替代方案?
Hi,
I''m facing problem while reading email attachment as .msg or .eml extension, it does not save on disk or also show null while seeing in attachment[] in debug mode. can you please help/resolve the issue or advise alternate.
private void GetAttachNames( out MailAttach[] aat )
{
aat = new MailAttach[ lastMsg.fileCount ];
Type fdtype = typeof(MapiFileDesc);
int fdsize = Marshal.SizeOf( fdtype );
MapiFileDesc fdtmp = new MapiFileDesc();
int runptr = (int) lastMsg.files;
for( int i = 0; i < lastMsg.fileCount; i++ )
{
Marshal.PtrToStructure( (IntPtr) runptr, fdtmp );
runptr += fdsize;
aat[i] = new MailAttach();
if( fdtmp.flags == 0 )
{
aat[i].position = fdtmp.position;
aat[i].name = fdtmp.name;
aat[i].path = fdtmp.path;
}
}
}
[edit]从OP注释中添加的代码-OriginalGriff [/edit]
[edit]Code added from OP comment - OriginalGriff[/edit]
推荐答案
这篇关于使用简单的MAPI(MAPI32)读取.msg/.eml附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!