0

When DLP policy is enabled, Redemption fails with the error: "All business e-mail messages are protected based on a policy set in your organization. There was an error opening the protected e-mail message."

ulLowLevelError: 2147746578 (i.e. 0x80040312)
ulContext: 805701633 (0x30060801)

Is there any way around this?

The error occurs when trying to access the IPMRootFolder property of a Store object:

// A previous version of the code was multi-threaded, it is no longer.
Session = OutlookRpcLoader.new_RDOSession();
Session.Logon(ProfileName: profile, ShowDialog: false, NewSession: true);
var stores = Session.Stores;
var store = stores["{STORE-NAME}"];
var root = store.IPMRootFolder;

The call stack shows that Redemption.IRDOStore.get_IPMRootFolder() threw the exception.

Edit

This is seen when using Redemption version 5.22.0.5498 loaded via the RedemptionLoader class in .NET (registry-free COM).
When testing with Redemption version 5.19.0.5238 from VBScript using CreateObject(), the error doesn't occur.
Could anything have changed between v5.19 and v5.22?

tjleigh
  • 1,134
  • 1
  • 10
  • 23
  • Which line of your code raises that exception? – Dmitry Streblechenko Jun 21 '21 at 10:12
  • Question updated with sample code – tjleigh Jun 21 '21 at 11:10
  • Hmmm... Is this a standalone app? Or is it in an addin? – Dmitry Streblechenko Jun 21 '21 at 11:39
  • It's standalone, .NET Framework 4.8. I will be trying to use a VBScript on Wednesday to see if it is the same from there (I expect it will be) – tjleigh Jun 21 '21 at 12:31
  • I ma just thinking there might be a different in calling RDOSession.Logon vs setting the RDOSession.MAPIOBJECT property to Application.Session.MAPIOBJECT. – Dmitry Streblechenko Jun 21 '21 at 15:25
  • Because we're not inside Outlook we don't have access to Outlook's MAPIOBJECT but, you could be on to something: because the app is multi-threaded I store the session's MAPIOBJECT after logon and assign it when accessing from other threads (I'll update the question with the code) – tjleigh Jun 21 '21 at 19:23
  • But inside Outlook, there is absolutely no issue accessing that store, right? I have never seen that error before - what kind of store is it? – Dmitry Streblechenko Jun 22 '21 at 03:37
  • No issues using the store in Outlook. No issues using the store from VBScript using v5.19. The store kind is skPrimaryExchangeMailbox. – tjleigh Jun 23 '21 at 10:25

2 Answers2

0

First of all, you need to detect where your code is running - whether it is the foreground or background thread. I'd suggest checking the ThreadID of the process. The foreground thread has the value set to 1. All background threads will values greater than one. If it is a secondary thread you need to create a new Redemption session on a secondary thread where you are going to use and set the MAPIOBJECT property to the object retrieved from the main thread. For example, a raw sketch in VB.NET:

Dim PrimaryRDOSession As New Redemption.RDOSession()
PrimaryRDOSession.Login([...])
Dim WorkerThread as New System.Threading.Thread(AddressOf ThreadProc)
WorkerThread.Start(PrimaryRDOSession.MAPIOBJECT)

Sub ThreadProc(ByVal param as Object)
    Dim ThdRDOSession As New Redemption.RDOSession()
    ThdRDOSession.MAPIOBJECT = param
    ' do other stuff
End Sub

Don't use objects created on the main thread if you are on a secondary one. Ensure you are consistent when using the objects.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • Thanks, I'm certain that I'm doing very similar to this already. I store the MAPIOBJECT after logon and re-use it on other threads. – tjleigh Jun 23 '21 at 10:27
0

I believe this was caused by AppLocker rules blocking unsigned binaries. The resolution was to either code-sign the files or add the program to the AppLocker allow-list.

tjleigh
  • 1,134
  • 1
  • 10
  • 23