private bool InitialiserMethodForMsgFile() { if (String.IsNullOrEmpty(m_fileData.Filename)) { return IsOutlookMSGType(m_fileData.BinaryFileData); } // Although the InitialiserMethod attribute is used to call this handler specifically for .msg files, // it is also called for unknown file types so therefore don't assume that the file is a .msg // ...however! just because it has no extension it doesn't mean it isn't a valud msg file, for embedded msg objects we remove the .msg extension, // so for these perform a low level filetype check. string extension = Path.GetExtension(m_fileData.Filename); // Simple extension check (if extension present) if (!string.IsNullOrEmpty(extension) && String.Compare(extension, ".msg", true) != 0) { return false; } // Full check for files with no extension if (string.IsNullOrEmpty(extension) && !IsOutlookMSGType(m_fileData.BinaryFileData)) { return false; } m_fileData.FileType = FileType.Email; m_impl = new EmailContainerImpl(m_fileData); return true; }
private bool InitialiserMethodForEmailFile() { string fileHeader = "[A04C0FB0-AFE4-4ffd-B470-6824AEFA6ED9]"; string subject = "[08335717-0310-4700-A063-3AA8EA2BD752]"; string body = "[8FBD1F28-8EFD-4af7-A4F7-1DF6A4AA9996]"; string attachments = "[E2AD1FFA-2567-4e7c-A73F-7C0828DB6765]"; string header = m_fileData.BinaryFileData.AsString(80, Encoding.Unicode); if ((header.IndexOf(fileHeader) != -1) || (header.IndexOf(subject) != -1) || (header.IndexOf(body) != -1) || (header.IndexOf(attachments) != -1)) { m_impl = new EmailContainerImpl(m_fileData); return true; } return false; }