Issues using .NET API in Windows 2016?

Discussion for developers using MailEnable.
Post Reply
mkucera
Posts: 5
Joined: Wed Jan 17, 2018 2:50 pm

Issues using .NET API in Windows 2016?

Post by mkucera »

I've just recently upgraded my server from Windows 2008 Server to Windows 2016 Server, and migrated a small .NET application that uses the MailEnable API. i think i use 4 API calls, and for some reason 1 has stopped working on my new server. Can someone please review the calls below and advise? The premise of the application is that i look for messages in an inbox. When they are found i read the message and do some processing and then delete the message. This continues in a loop until all messages in the inbox are processed.

Code: Select all

MailEnable.Store storeMessage = new MailEnable.Store();  /THIS CALL WORKS FINE
storeMessage.StoreFolder_Open(ConfigurationManager.AppSettings["PostOfficeName"], "INCOMING", "\\Inbox", storeMessage.MessageClass, 1); //SO DOES THIS CALL

if (storeMessage.StoreFolder_FindFirstItem() == 1) //THIS CALL IS WORKING!
{
  do
  {
          //get the message id
          /****************************************************************************************************/
          /*   THE NEXT LINE IS THE CALL THAT IS FAILING.  WELL IT DOESN'T FAIL, BUT IT DOESN'T  */
          /*   RETURN THE MESSAGE ID ANY MORE.  AFTER THIS LINE RUNS, messageid == "" */
          /*  WHICH IS NOT THE EXPECTED RESULT.  PREVIOUSLY THIS CALL WOULD RETURN  */
          /*  SOMETHING THAT LOOKED LIKE A GUID FILENAME WITH A .MAI EXTENSION  */
          string messageid = storeMessage.StoreItem_GetProperty("ME_ITEM_ID").ToString();
                   
         
        long lResult = 0;
        lResult = storeMessage.StoreFolder_DeleteItem(messageID);  //NO ISSUES DELETING
        lResult = storeMessage.StoreFolder_Save(); //THIS ALSO IS GOOD!

  }
  while ((storeMessage.StoreFolder_FindNextItem() == 1));  //WORKS!
}

I've attempted to put a breakpoint on the call that is failing to see if i can examine the object, but it doesn't really show anything. presumably because the assembly is just a COM wrapper, i guess. Is there something different i need to do to get this to work in this environment? I was able to get around this issue by using the Standard DirectoryInfo class in .Net and manually retrieving the name of the first .MAI file in the INBOX directory. ironically this works for what i need and all the API calls that follow work as expected with this workaround in place. it is definitely a workaround however and i'd like to know what i need to do or change for the storeMessage.StoreItem_GetProperty("ME_ITEM_ID") to work again.

Thanks for your help!
-Mark

Post Reply