Note: I was asked to create an app that extracts .msg files from a .pst file preferably in MFC. I was informed that they have tried to use other 3rd party apps but they all fail
If you really need to write your own application, then you must start by searching and downloading the PST specification. LMGTFY... Ah, you can find it on MSDN:
[MS-PST]: Outlook Personal Folders (.pst) File Format.
Only then can you determine what tools you need for the job, and which programming languages will help you best.
It looks like a well specified binary format. So any language that will allow you to read binary files (both MFC and C# can do this well) will do the job. There may be third-party libraries available for reading .PST files, but you'll really have to search those yourself and evaluate them according to your criteria. For example:
MSG .NET (C# library).
It does exactly what you need, extract all messages as .msg files from a .pst file.