Possible bug in codeunit 4508 "Email - Outlook API Client"
Our customer have some emails that sometimes cannot be sent and end up as "failed email" in the new advanced email functionality. I have a hard time debugging this because I think the error message that is shows is not correct.
In the log I can see status “Failed” with error message “Data does not represent a valid JSON token.”. The call stack can be seen here below.
I think the error is created in function “GetHttpErrorMessageAsText” on the line ResponseJson.Get('error', JToken); on some responses. I am not able to reproduce this because most of the time it work, i can also not inspect the data. Could try to find this if you point me in the right direction.
What do you think?
"Email - Outlook API Client"(CodeUnit 4508).GetHttpErrorMessageAsText - Email - Outlook REST API by Microsoft "Email - Outlook API Client"(CodeUnit 4508).SendMailSingleRequest - Email - Outlook REST API by Microsoft "Email - Outlook API Client"(CodeUnit 4508).SendEmail - Email - Outlook REST API by Microsoft "Email - Outlook API Helper"(CodeUnit 4509).Send line 14 - Email - Outlook REST API by Microsoft "Microsoft 365 Connector"(CodeUnit 4503).Send line 4 - Email - Microsoft 365 Connector by Microsoft "Send Email"(CodeUnit 8890).OnRun - System Application by Microsoft "Email Dispatcher"(CodeUnit 8888).OnRun - System Application by Microsoft "Email Impl"(CodeUnit 8900).Send - System Application by Microsoft "Email Impl"(CodeUnit 8900).Send - System Application by Microsoft "Email Editor"(CodeUnit 8906).SendOutbox - System Application by Microsoft "Email Editor"(Page 13)."Send - OnAction" - System Application by Microsoft "Email Editor"(CodeUnit 8906).Open - System Application by Microsoft "Email Impl"(CodeUnit 8900).OpenInEditor - System Application by Microsoft Email(CodeUnit 8901).OpenInEditorModally - System Application by Microsoft "Mail Management"(CodeUnit 9520).SendViaEmailModule line 35 - Base Application by Microsoft "Mail Management"(CodeUnit 9520).DoSend line 6 - Base Application by Microsoft "Mail Management"(CodeUnit 9520).Send line 12 - Base Application by Microsoft "Mail Management"(CodeUnit 9520).SendMailOrDownload line 7 - Base Application by Microsoft "Email Item"(Table 9500).Send line 5 - Base Application by Microsoft "Document-Mailing"(CodeUnit 260).EmailFileInternal line 61 - Base Application by Microsoft "Document-Mailing"(CodeUnit 260).EmailFile line 12 - Base Application by Microsoft "Report Selections"(Table 77).SendEmailDirectly line 41 - Base Application by Microsoft "Report Selections"(Table 77).SendEmailToCustDirectly line 23 - Base Application by Microsoft "Report Selections"(Table 77).SendEmailToCust line 36 - Base Application by Microsoft "Document-Print"(CodeUnit 229).DoPrintSalesHeader line 16 - Base Application by Microsoft "Document-Print"(CodeUnit 229).EmailSalesHeader line 2 - Base Application by Microsoft SalesDocReleaseSub_XXXXXXX(CodeUnit 50106).OnAfterManualReleaseSalesDoc line 7 - XXXXXXXXXX "Release Sales Document"(CodeUnit 414).OnAfterManualReleaseSalesDoc line 2 - Base Application by Microsoft "Release Sales Document"(CodeUnit 414).PerformManualRelease line 10 - Base Application by Microsoft "Sales Order"(Page 42)."Release - OnAction"(Trigger) line 4 - Base Application by Microsoft
Hey @CarlOhlsson
Thanks for reporting this. We'll take a look into this issue and get back to you soon.
Hey @CarlOhlsson
Thanks for reporting this. We'll take a look into this issue and get back to you soon.
Thank you, we currently have 65 cases since 2021-01-21 that i can see in table Email Outbox (8888).
Hey @CarlOhlsson Thanks for reporting this. We'll take a look into this issue and get back to you soon.
Thank you, we currently have 65 cases since 2021-01-21 that i can see in table Email Outbox (8888).
Do you have a consistent repro for this issue?
I haven't been able to repro. If successful, this method should return 202 Accepted response code, otherwise it should return valid JSON with an error object.
Without repro, the best I can do is throw a more suitable error message.
Hey @CarlOhlsson Thanks for reporting this. We'll take a look into this issue and get back to you soon.
Thank you, we currently have 65 cases since 2021-01-21 that i can see in table Email Outbox (8888).
Do you have a consistent repro for this issue?
I haven't been able to repro. If successful, this method should return 202 Accepted response code, otherwise it should return valid JSON with an error object.
Without repro, the best I can do is throw a more suitable error message.
I have no way to reproduce the error, i can only look at logs and Business Central code. Just now did a test with the customer to resend one the the emails and it was sent successfull. If i look on the exchange server and trace the recipient i can also see that it got delivered to the recipient successfully the first time even if it is "Failed" in Business Central. Right now it looks like the error messages in Business Central are false because our email got sent if we look in the exchange log.
I did notice on the exchange that at the time of sending the mail from Business Central we got an incomming email simultaniusly. May be this result in a strange response? Could also be why we can not reproduce it.
Availability update: We will publish a fix for this issue in the next update for release 18.
Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.