1

In the company I work for we are using redemption to send emails from our old Delphi client. We have used it for many years, but after the upgrade to Office365 - outlook 1906 this error has started occurring.

The issue occurs on all our version of the software, from versions going back 5 years to versions we have compiled a few days ago.

The error occurs randomly, however once it happens it will continue until a full machine reboot. So usually a reboot makes it possible to send mails again for a few hours, but the error will eventually occur again.

The error occurs when uSafeMailItem is being created The error does not occur in previous versions of Office365 (Before Outlook 1906)

The error we log is OLE error 8004010E, ProgID: "UnikOR.uSafeMailItem" aka MAPI_E NOT ENOUGH RESOURCES (UnikOR.uSafeMailItem equals Redemption.SafeMailItem)

After investigating so many days we seem to have come to the conclusion it is either Redemption, or more likely the way we use Redemption or something?

We have tested combinations of outlook and windows

Windows and outlook version

  1. Windows 10 Enterprise 1803

    • Outlook 1904 (Works)
    • Outlook 1906 (Fails)
  2. Windows 10 Enterprise 1809

    • Outlook 1904 (Works)
    • Outlook 1906 (Fails)
  3. Windows 10 Enterprise 1903

    • Outlook 1904 (Works)
    • Outlook 1906 (Fails)

We have checked the memory available in outlook through the tool called VMMap

VMMap

I can also see that outlook have some dead processes hanging. But I am not sure if that has anything to do with Redemption

RamMap

I also enabled Outlook logging and received a log file (OUTLOOK-20190806T1236220570-v2.etl). However, I don't seem to find anything that could be related to Redemption and the way it calls outlook.

We also looked with Procmon, and Fuslogvw without any luck.

This code below creates the object

function TSendEmail.SendOutlookEmailUsingRedemption(Outlook: Olevariant; OutlookEmailFileName: string; var Email: TStream; var Subject: string; var HasAttachments: Boolean; UseOutlookSignatur: Boolean): TMailSendResult;
var
  Utils: IMAPIUtils;
  RDOSession: IRDOSession;
  SentMailFolder: IRDOFolder;
  RDOMailItem: IRDOMail;
  MailInSentFolder: IRDOMail;
  Body: string;
  I: Integer;
  Insp: Variant;
  TempInsp: Variant;
  MailItem: Variant;
  OutlookEntryID: string;
  S: string;
  SafeItem: ISafeMailItem;
  SL: TStringList;
  TempBody: string;
  OutlookSignatur: string;
begin
  Result := msrOK;
  FMailData.MailAttachments.PrepareNotes;
  try
    MailItem := Outlook.CreateItem(olMailItem);
    SafeItem := CreateOLEObject('UnikOR.uSafeMailItem') as ISafeMailItem; // do not localize
    Variant(SafeItem).Item := MailItem;
function TSendEmail.SendOutlookEmail(var Email: TStream; var Subject: string; var HasAttachments: Boolean; UseOutlookSignatur: Boolean): TMailSendResult;
var
  Outlook: Olevariant;
  OutlookEmailFileName: string;
  OutlookEntryID: string;
begin
  try
    OutlookEmailFileName := FTempPath + 'OutlookEmail.msg'; // do not localize
    try
      Outlook := GetActiveOleObject('Outlook.Application'); // do not localize
    except
      Outlook := CreateOleObject('Outlook.Application'); // do not localize
    end;
    if FMailData.UseOutlookRedemption then
      SendOutlookEmailUsingRedemption(Outlook, OutlookEmailFileName, Email, Subject, HasAttachments, UseOutlookSignatur)
    else
      SendOutlookEmailUsingMapi(Outlook, OutlookEmailFileName, Email, Subject, HasAttachments, UseOutlookSignatur);

We expect it to send the email to the target email address, however instead our system uses the fall back method what is to print the document and sends us the following error "Error: OLE error 8004010E, ProgID: "UnikOR.uSafeMailItem""

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
HitzSPB
  • 158
  • 10

1 Answers1

1

Every time a creatable Redemption object is created, it initializes the MAPI system by calling MAPIInitialize. When it is destroyed, it calls MAPIUnitialize. Outlook does not like having the MAPI system continuously cycling - the rule of thumb is to initialize the MAPI system once and leave it initialized. You can create a Redemption object (such as another SafeMailItem object or RDOSession) once and keep it alive for the lifetime of your app.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • Sorry for the delayed answer. While we were implementing this in our solution and started testing. Microsoft have pushed out 1907 version and the issue seem to be gone in that version for all our customers. – HitzSPB Aug 16 '19 at 09:48