Save the mails in mailbox to a LAN folder using C# RRS feed

  • Question

  • Hi,

    I am looking for a best way to save the mails in mailbox  to a LAN folder.
    This saving process needs to be scheduled daily.
    I tried using Microsoft.Office.Interop.Outlook.Application to automate this mail saving process.
    But unfortunately it is prompting a security alert message either to Allow or Deny the access and in some machines it prompt the user to enter password

    Since my task needs to be scheduled it doesn't require any manual intervention to run this.
    I want to bypass this message and  save the messages and attachment to a local folder.

    Can anyone advice on this?

    Wednesday, December 21, 2016 3:07 AM

All replies

  • Short answer - make sure the machine has up-to-date anti-virus app installed to avoid prompts.

    If your cannot control the environment, Extended MAPI (C++ or Delphi), Redemption (any language) or ClickYes are you choices.

    See for a detailed discussion.

    Dmitry Streblechenko (MVP)
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, December 21, 2016 3:31 AM
  • Hello Saira,

    You get a standard security prompt in Outlook. Security Manager for Microsoft Outlook allows to suppress such warnings. Also you may consider using a low-level API (Extended MAPI) which doesn't trigger any security prompts.

    But I have noticed the following statement in your post:

    > Since my task needs to be scheduled it doesn't require any manual intervention to run this.

    Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

    If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. Read more about that in the Considerations for server-side Automation of Office article.

    As a workaround you may consider using a low-level API on which Outlook is based on - Extended MAPI (or any other third party wrappers around that API, for example Redemption). Also you may search for other components that don't require Outlook installed on the machine at all.

    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Wednesday, December 21, 2016 10:37 AM