But there is an issue with converting Outlook message files (.msg) to text
files. When trying to read the msg file with an Outlook object, a pop-up
window comes from Outlook saying that a program is trying to access Outlook.
So the users always have to grant access to the application whenever they try
to generate a text file from msg files.
The code block is shown below.
The variable “path” contains the file path to the message file.
// Create Outlook Application Object
Microsoft.Office.Interop.Outlook.ApplicationClass objOutlook =
newMicrosoft.Office.Interop.Outlook.ApplicationClass();
//Create Null Ref Object
object nullobj = System.Reflection.Missing.Value;
// Outlook Mail Object
Microsoft.Office.Interop.Outlook.MailItem msgItem;
// Open Mail file
msgItem =
(Microsoft.Office.Interop.Outlook.MailItem)objOutlook.CreateItemFromTemplate(path,nullobj);
// Extract Plain Text
string plainText = msgItem.Body.ToString();
// Cleanup Resources.
objOutlook.Quit();
objOutlook = null;
return plainText;
The application uses COM INTEROPS of Office XP, Office 2003 and Office 2007
to generate text files. First, the available version is checked and then uses
INTEROPS of that particular version to generate text files.
The application doesn’t need to access the Outlook application, because
users select a file available in the local file system using a file-open
dialog box.
We need to find a solution to stop appearing the pop-up warning so that
users don’t have to respond to the warning message.
http://www.slipstick.com/outlook/esecup.htm#autosec
--
Jocelyn Fiorello
MVP - Outlook
*** Messages sent to my e-mail address will NOT be answered -- please reply
only to the newsgroup to preserve the message thread. ***
Thank you very much for your quick response. This application runs in
standalone machines and therefore cannot use administrative options to
suppress the warning message.
This application is developed with .Net 1.1 and C#. Since Extended Mapi is
only available for C++ (and Delphi) developers and since my objective is to
simply convert a msg file to a text file, and also I’ve read in many places
where developers mention to get away of Eextended Mapi if possible due to the
complexity of the low level language, I thought of searching for other
solutions.
I’ve already come across those third party components such as Redemption and
Advanced Security but continued to search for more solutions to check whether
it is possible without using a third party component or by using an ideal
component which is available for free. But thank you so much for your kind
efforts for providing this information.
Best Regards,
Dilum
However, recently an enterprising developer has hacked the .msg format to provide a way to access its data directly. See http://www.outlookcode.com/codedetail.aspx?id=1561
FYI, there is a newsgroup specifically for general Outlook programming issues "down the hall" at microsoft.public.outlook.program_vba or, via web interface, at http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.outlook.program_vba
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
"Dilum" <Di...@discussions.microsoft.com> wrote in message news:5B185D4C-563C-4E75...@microsoft.com...
Best regards,
Dilum
• Using CDO (Collaborative Data Objects ) API by Microsoft
• Using third-party components (Rebex, aspNetMime)
• By developing an API for manipulating EML files directly
Although I managed to use CDO in Windows XP environment where Microsoft
Exchange Server 2000 was not available, it is mainly developed to be used
with Windows 2000 environments. So it makes me uncomfortable to release the
component that uses CDO for the customers.
Also the small test project I did showed that CDO is not 100% accurate for
manipulating EML files. It didn’t return important information such as the
sender’s address and the date it returned was also incorrect.
Third party components were working fine, but I am still looking whether
it’s possible without using third party libraries because they are very
expensive.
Since the message structure of EML type is fairly simple processing it
directly would be another solution.
Can you please tell me if there are any other ways to convert EML files to
text files?
Best regards,
Dilum
PMFJI, if you want free and you don't want to change your code, I suggest
you try:
http://www.contextmagic.com/express-clickyes/
You can even call this from your program before you get to the bit of code
that accesses Outlook, do your stuff, let it click the Allow button for you
automatically, then close it down from your code.
--
John Blessing
http://www.LbeHelpdesk.com - Help Desk software priced to suit all
businesses
http://www.room-booking-software.com - Schedule rooms & equipment bookings
for your meeting/class over the web.
http://www.lbetoolbox.com - Remove Duplicates from MS Outlook, find/replace,
send newsletters
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
"Dilum" <Di...@discussions.microsoft.com> wrote in message news:4F40C3EE-6F52-42A3...@microsoft.com...
Thank you very much for your support.
Best regards,
Dilum
"Sue Mosher [MVP-Outlook]" wrote:
> Every .eml file I've ever looked at *is* a text file. Sorry, but since ..eml files have nothing to do with Outlook programming, I don't know anything more about conversion methods other than what you can do with Outlook Redemption. A messaging forum or a general Windows programming forum might be a better place to ask about this.