Disable Outlook Security Message Box - c#

I am developing outlook 2007 add in, and facing problems with Outlook Security MessageBoxes.
I know that i can disable it from the trust center and set allow programmatic access to true,
but i want to disable it by code.
How can i disable Outlook Security MessageBox by code?
Note: I am using C# and VSTO.

Ok,
The security guard pops up when you try to access certain properties of the mail mainly around the email addresses. You can use mapilib to stop it or use redemption's safe mail item. or
You can use the mail items PropertyAccessor to gain access to the underlying Mapi properties
For the "TO" you need PR_EMAIL_ADDRESS (or PR_SMTP_ADDRESS)
mailItem.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3003001F");
I would suggest that you download Dimitry's Outlook spy its "the" tool if you are developing Mapi/outlook etc.
You can then look up the Mapi properties and their ids to get the others

Related

How to Read/Write Contacts and Events in Outlook when it is set to Work Offline - C#

As the Title suggest, i am trying to Read and Write (R&W) Contact and Event information to multiple Outlook Accounts/Profiles in a local computer, while Outlook is set to Work Offline.
So far i discovered two ways to R&W contacts and Events to Outlook:
1.- Microsoft.Graph:
This seems to work only online, since it reads and writes to the Microsoft server, not to the local pst/ost files.
2.- microsoft.office.interop.outlook library:
This does work offline/locally (by accessing the Outlook pst/ost files) but the approach i am using so far requires the creation of an Application object as
var app = new Microsoft.Office.Interop.Outlook.Application();
Nevertheless, creating an Application object implicitly logs in a profile/user to the application, and further, if Outlook is already running and logged in with a Profile X, the code above instantiates an Outlook object in which the Profile X is logged in, so in that scenario i can only R&W Contacts and Events for that specific user/Profile.
So, is there a way to be able to R&W Contact and Event information for different profiles independently of if Outlook is running with a Profile X?
Well, there is no magic - if you want offline access, something needs to implement the storage to keep the cached data and cache your changes so that they can be uploaded when the server comes back online.
If you don't want to implement that logic, cached Outlook profile is probably your only choice. You are right that Outlook, being a singleton, can only access one profile at a time. You can use Extended MAPI to access a profile other than the other used by Outlook, but it is C++ or Delphi only. If using Redemption is an option (I am its author), it wraps Extended MAPI API for use in any language (C# included) - you can use its RDOSession.Logon method to access any existing profile.

Outlook Interop Security

I am writing a C# Console application which shall be able to search through my emails.
I use the Interop Outlook dll to connect and can access the emails fine, but I always get a popup windows which asks me if I want to allow access to Outlook.
I understand that this is a secruity dialog and is needed so viruses cannot access my mails. I have already written an Outlook Add In in the past and never got the dialog. I guess this is because the code was executing from inside Outlook.
Is there any possibility do store my console app id and always grant access?
If there is no way around the dialog, is there any other way to search my local emails withing a C# console application?
The Systems specs are:
Server 2012 R2 Datacenter,
Visual Studio 2013 update 4 and
Outlook 2013
You see the standard security prompt in Outlook. You can do the following to avoid it:
Use the Security Manager component for supressing the security prompts in Outlook.
Use a low-level API which doesn't generate such security prompts - Extended MAPI. Or any other third-party wrappers around that API such as Redemption.
Deploy Outlook security settings (for administrators).
You can read more about all of these ways on the Outlook "Object Model Guard" Security Issues for Developers page.
We encountered this issue on a recent Windows Server deployment. The server has Office 365 installed and upto date Symantec Antivirus, for this reason, we overrode the default Programmatic Access Security Setting (while we investigate the Antivirus detection issue).
In Outlook go to File -> Options -> Trust Center -> Trust Center Settings -> Programmatic Access
[UPDATE]: After performing an update on the Antivirus Software and downloading the latest definitions, the status within Outlook changed to "Valid".

Getting data from e-mail to c#

I wonder it is possible to get data from email message to c#?
It is?
If you have got an account configured in Outlook you may consider automating it. See How to automate Outlook from another program for more information. And C# app automates Outlook (CSAutomateOutlook) for sample code.
Also you may consider developing a managed add-in for Outlook. In that case you will be able to handle Outlook events and track what users do. See Walkthrough: Creating Your First Application-Level Add-in for Outlook for more information.

C# + Information Rights Management

I need to avoid forwarding in the emails that I'm sending using .NET. I'm using Outlook and Exchange server and I read tha IRM can help me. Does anyone have any code example or know if it's possible?
It looks like you might be able to use the Microsoft Outlook 2010 Primary Interop assembly and set the PermissionTemplateGuid property of the MailItem you're sending.
Note that you'll have to know the Guid of an IRM policy that prevents forwarding of the email.
You cannot send IRM mail programmatically in Outlook 2010. IRM mail is actually a regular mail message with an encrypted attachment, and Outlook does not expose the right API to craft the encrypted attachment and change the mail type.
The only way to do it from C# code is to use ActiveSync and send the mail in Exchange directly. Unfortunately, as of Exchange 2010, only licensed vendors can use ActiveSync.
See http://www.microsoft.com/about/legal/en/us/intellectualproperty/iplicensing/programs/exchangeactivesyncprotocol.aspx for more information.
Also, if you go down the path of setting the template guid, know that the DoNotForward template guid is hard-coded -- if it actually works (this is untested and unsupported, so you're mileage will vary) then you don't need to bother looking up the RMS template.

Open Microsoft Outlook from winforms C# (.net 3.5) application in reply mode

I open outlook from my Winfoms application. I want to open outlook in reply mode. How can I do this.
Thanks.
so you want to open outlook and have it ready to send an email to a prefered receiver.
the quick and dirty fix i think is to have a hidden webbrower in your program and let the browser navigate to mailto:mail#mail.com?subject=somekindsubject
which will open the default email client on the machine.
System.Diagnostics.Process.Start("mailto:youremailaddress#whatever.com");
The mailto can be used with a lot of parameters
Check out the parameters here
http://msdn.microsoft.com/en-us/library/aa767737(VS.85).aspx
http://www.ietf.org/rfc/rfc2368.txt
Eg (Taken from MSDN)
mailto:user#example.com?subject=MessageTitle&body=MessageContent
UPDATE:
Attachments i think are not supported due to security reasons and I strongly agree with it as well.
However Outlook 2003 seems to be accepting the parameter "attachments" according to someone who has posted in MSDN.
string email = "mailto:name#domain.com?attachments=\"\"C:\\file.txt\"\"";
System.Diagnostics.Process.Start(email);
This is the best i could do and i cannot test it as I do not have Outlook 2003. But even if it works in Outlook 2003, i strongly urge you not to use the attachment parameter as it may not be supported by different programs.
You can use something like:
System.Diagnostics.Process.Start("mailto:mail#address.com?subject=Sample subject");
Which will open the default email application filling in the to and subject fields. You can find more options here.
Edit: this takes a bit of time on my system, so make sure that if your user has a slower computer they'll know what's going on. Also, you should handle the case when they don't have Outlook or another mail program installed if it's a possibility.

Categories

Resources