"Cannot create type NSEMailConnectionInfoExtended" in CRMScript

Hi,

I'm working on troubleshooting an issue with dowloading e-mails from a mailserver, and want to reproduce the issue using CRMScript.

However, in CRMScript it fails when trying to create an object of type NSEMailConnectionInfoExtended. It's in intellisense, but fails when script is executed. Could you fix this?

 

#setLanguageLevel 3;

NSEMailConnectionInfoExtended connection;

connection.SetFolder("Inbox");
connection.SetPassword("test");
connection.SetPort(443);
connection.SetProtocol("pops");
connection.SetServerName("test.example.com");
connection.SetUserName("username");
connection.SetUseSSL(true);

NSEMailAgent m;
String[] ids = m.GetEmailMessageIds(connection);

for (Integer i = 0; i < ids.length(); i++)
  printLine(ids[i]);

RE: "Cannot create type NSEMailConnectionInfoExtended" in CRMScript

The issue I'm troubleshooting, by the way is this. An e-mail is stuck in the Exchange-mailbox, and blocks all the other emails from downloading. This is the extended log from importMail.

->fetchMailFromNetServer()
Fetching from: imaps://support@example.no:XXXX@outlook.office365.com:993/Inbox type=6
(....)
NSEMailAgent::GetEmailMessageIds (Time: 1.140333 s)
1 messages found
(....)
importMail 2.0: NetServerException (NetServer exception: Service call EMail.GetEmailsAsString failed with exception
EMail.GetEmailsAsString

Unable to find message id:

) in :-1
NetServerException: NetServer exception: Service call EMail.GetEmailsAsString failed with exception
EMail.GetEmailsAsString

Unable to find message id:


filterSuccess=0
Von: Frode Lillerud 30. Jan 2020

RE: "Cannot create type NSEMailConnectionInfoExtended" in CRMScript

Hey Frode,

Can't help you with the code but we had an email stuck at a customer, we solved this by login into OWA(Outlook web access) using the IMAP account and doing a empty folder operation on the inbox folder.

Von: David Hollegien 30. Jan 2020

RE: "Cannot create type NSEMailConnectionInfoExtended" in CRMScript

Hi David, 

we're one step closer to tracking down the cause.

Using Postman I'm calling the WebApi, and ask it to get the MessageId's. Here we see that the problem-mail returns NULL as its message-id, and it's blocking the next four emails from downloading.

This will cause the next call, the one that uses GetEmailsAsString, to fail with the error "Unable to find message id".

When logging into Outlook I see that the blocking e-mail has a Message-ID set, so not sure why GetEmailMessageIds says it is NULL. Maybe a bug in the E-mail library used in NetServer?

Von: Frode Lillerud 30. Jan 2020

RE: "Cannot create type NSEMailConnectionInfoExtended" in CRMScript

Hi,

the message-id in question does not seem to confirm to the spec (rfc822) as I believe the ":" is a SPECIAL character and should be inside quotes. Maybe that is the reason. I think we should be more tolerant of divergent email agent behavior than this, so I will put it on my short list of things to investigate at first opportunity:-)

The issue with the script failing is now on the same list, and I will look into it.

Ideally both will be fixed in R11, but no promises:-)

Von: Erik Knudsen 31. Jan 2020

RE: "Cannot create type NSEMailConnectionInfoExtended" in CRMScript

Sounds very good, Erik, thanks!

Von: Frode Lillerud 31. Jan 2020

RE: "Cannot create type NSEMailConnectionInfoExtended" in CRMScript

Erik, when checking the customers database today we see that they have been able to import many other e-mails from the same sender, where the Message-ID has similar format. So even though the Message-ID doesn't conform to the RFC822 spec it seems like most of the times it still works. Could there be something else in the header that confuses GetEmailMessageIds?

Von: Frode Lillerud 3. Feb 2020

RE: "Cannot create type NSEMailConnectionInfoExtended" in CRMScript

Yes,

it's a good thing that we tolerate the message ids that are not confirming, but there might be other causes for the problem with the one email. I'm not sure if it's your editor or not, but does the line with the message id actually have a line break? If it does, it doesn't seem to follow the header folding rules.

 

Regards,
Erik Knudsen

Von: Erik Knudsen 3. Feb 2020

RE: "Cannot create type NSEMailConnectionInfoExtended" in CRMScript

Regarding the GetEmailMessageIds web api method, it asks the server to provide the messageids, and the server fails for this one. Not sure why. Weird if the server accepts the other similar messageIds. On our side, parsing of the email data seems to work fine, using the example you provided. Maybe you can use another web api method? Or expirement by using thunderbird - hook up both this problem email account and your test account in thunderbird, and copy-drag the message to your account inbox folder to make a copy of it on your imap server, then connect to the test server and see what happens.

Regarding the EmailAgent and the Carrier objects that cause a run time error in CrmScript, most of the EMailAgent was left out of CS some time ago, before we had proper proxy support in our online environment, as a security measure. But now it shouldn't be a problem IMHO. We will review this decision with our security partner Watchcom today and if ok, we will attempt to get this done in the R11 relese we are working on at the moment.

Von: Erik Knudsen 4. Feb 2020

RE: "Cannot create type NSEMailConnectionInfoExtended" in CRMScript

Hi, 

I did an experiment now. I created a new gmail account, and hooked up both the customers Exchange email account and my demo account in Thunderbird. Then I dragged the problematic e-mails from the customers inbox over to my gmail inbox. Running the same test against my Gmail inbox now gives this (there are 13 problem-emails here, and one normal email)

For some reason they now get a "<randomnumber>@unknownmsgid". Perhaps that is just how GMails handles errors, while Exchange returns NULL.

By dragging the e-mail from Thunderbird to my Desktop, editing the file in Notepad++, and dragging it back into Thunderbird I'm able to experiment with various examples. Doing that, I see that I can reproduce the problem by using colon in the Message-ID.

This works:

Message-ID: <foo.bar@example.com>

While this will cause it to fail:

Message-ID: <foo:bar@example.com>

Also, since Gmail handles the error differently, by generating a random messageId when the format is wrong, SuperOffice is still able to download the email. On Exchange however it returns NULL and then SuperOffice can't download it.

Von: Frode Lillerud 8. Feb 2020

RE: "Cannot create type NSEMailConnectionInfoExtended" in CRMScript

Hi again, another update from here. We see that changing from IMAPS to POPS fixes the issue.

The emails that are blocking download when using IMAPS works fine with POPS. Calling the GetEmailMessageIds method when using POPS gives a number instead of NULL for the problem e-mail. I assume IMAPS and POPS has a different perception of what ID to use, and the problem with illegal Message-ID headers doesn't affect POPS.

So, conclusion is that the problem happens when all these are true at the same time:

  • Message-ID header contains colon
  • E-mail server is Office365 Exchange
  • Uses IMAPS protocol

 

Von: Frode Lillerud 12. Feb 2020