I have a utility I built that checks an exchange email box and downloads attachments to a specified location. However, I'm running into a bug with messages that have another email attached to them (in *.msg). Whenever these pop up the attachments properties are not available so i can not access them to download them.:
versus when a zip or something like that comes in:
is there away to detect that this is an .msg attachment? or perhaps, "cast" it as such. I know I can wrap this in a try catch but i dont want to fall over into converting the attachment to a .msg when perhaps it is another file type that it is causing this.
Any help would be appreciated.
Zach
Just cleaning up my SO but here is how I solved this. The eml attachment is actually an "ItemAttachment" instead of a "FileAttachment" versus the generic "Attachment." So the loop looks like this:
foreach (Attachment att in itm.Attachments)
{
if (att is FileAttachment)
{
var fileAttachment = att as FileAttachment;
//do some stuff
}
else
{
var itemAttachment = att as ItemAttachment;
//do some more stuff (these are most likely eml/msg attachments...
}
}