Outlook security warning - A program is trying to access outlook

G

Guest

Our application converts various text document formats to text files. Users
can use the application to select a supported file (doc, pdf, msg etc.) to
generate a text file (.txt) .

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.
 
K

Ken Slovak - [MVP - Outlook]

Your options are to use the Exchange security form, a 3rd party library such
as Redemption (www.dimastr.com/redemption) or some utility such as ClickYes
(which can be a security threat). Other options such as Extended MAPI aren't
supported for managed code.
 
G

Guest

Hello Ken,

Thank you very much for your help. I was also looking for solutions to
convert EML files (.eml) to text. From my research I found following options.

• 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
 
K

Ken Slovak - [MVP - Outlook]

Sorry, I know nothing about EML files.




Dilum said:
Hello Ken,

Thank you very much for your help. I was also looking for solutions to
convert EML files (.eml) to text. From my research I found following
options.

• 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
 
D

Dmitry Streblechenko

You can use the IConverterSession (Outlook 2002 and up) built-in object from
Extended MAPI (C++/Delphi only)

<plug>
You can also use Redemption (url below) to create EML files - see
Safe*Item.SaveAs and RDOMail.SaveAs(..., olRFC822)

set sItem = CreateObject("Redemption.SafeMailItem")
sItem.Item = YourOutlookMailItem
sItem.SaveAs "c:\temp\test.eml", 1024

<plug>

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top