AdhocAdam / smletsexchangeconnector

SMLets PowerShell based Exchange Connector for controlling Microsoft System Center Service Manager 2016+
https://adhocadam.github.io/smletsexchangeconnector/
GNU General Public License v3.0
29 stars 19 forks source link

Mail with special characters not imported #307

Closed rbw87 closed 3 years ago

rbw87 commented 3 years ago

Installed and configured yesterday. It worked including the signed email (why we want to use this connector) Now as a test a user send an email with special characters: #&@^$(#@^$!$)!%&#@%!_($""'';.,/><?><":L}{L

As a result, I'm seeing a warning and two errors in the event viewer every 2 minutes (import interval). The email is not being imported.

Help us reproduce the bug Version of the connector you are using: Version 3.3.0.12

Expected behavior I expected the email to be imported, with special characters replaced if necessary. I expected the connector to run after removing the email from the inbox. It does run, but new mails are no longer imported.

Location and Environment Running from the workflow server, set to every 120 seconds. SCSM 2019 UR2 Not using any of the advanced features (AI / OCR).

Additional context Operations Manager errors/warning: EventID 26319 A Windows Workflow Foundation workflow failed during execution.

Workflow Type: SMLets.Exchange.Connector.Resources.RunScript

Workflow Identifier: 7bdb4c11-31b8-bf66-e2ef-54de5d109462

Exception Type: System.Management.Automation.CmdletInvocationException

Exception Message: Projection

Exception Stack: at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) at SMLets.Exchange.Connector.Resources.RunScript.Execute(ActivityExecutionContext SMEXCOContext) at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime) at System.Workflow.Runtime.Scheduler.Run()

EventID 33880: A Windows Workflow Foundation workflow failed during execution.

Workflow Type: SMLets.Exchange.Connector.Resources.RunScript

Workflow Identifier: 7bdb4c11-31b8-bf66-e2ef-54de5d109462

Exception Type: System.Management.Automation.CmdletInvocationException

Exception Message: Projection

Exception Stack: at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) at SMLets.Exchange.Connector.Resources.RunScript.Execute(ActivityExecutionContext SMEXCOContext) at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime) at System.Workflow.Runtime.Scheduler.Run()

EventID 33333 Data Access Layer rejected retry on SqlError: Request: p_ManagedEntityInsert -- (BaseManagedEntityId=46e898c1-e1b3-7a7b-c640-6a09f164ee46), (TypedManagedEntityId=46e898c1-e1b3-7a7b-c640-6a09f164ee46), (ManagedTypeId=eca3c52a-f273-5cdc-f165-3eb95a2b26cf), (FullName=System.Domain.User:tno.nl.IT-servicedesk-test), (Path=), (Name=tno.nl.IT-servicedesk-test), (TopLevelHostEntityId=46e898c1-e1b3-7a7b-c640-6a09f164ee46), (DiscoverySourceId=7431e155-3d9e-4724-895e-c03ba951a352), (HealthServiceEntityId=5fb83d4b-a274-6bba-96e1-6584a87bc395), (PerformHealthServiceCheck=False), (TimeGenerated=6/16/2021 7:00:52 AM), (IsOptimistic=True), (LifetimeRelationshipId=), (IsConnectorLoggingDisabled=False), (ConcurrentConnections=True), (LastModified=), (TypedInstanceInserted=False), (ChangeId=), (RETURN_VALUE=1) Class: 16 Number: 777980010 Message: Instance Id = {46E898C1-E1B3-7A7B-C640-6A09F164EE46} last modification is more recent than submitted.

AdhocAdam commented 3 years ago

Hey there @rbw87!

Thanks for raising this issue. So I can make by best attempt to reproduce this, the special characters are where? The subject? The body? The sender's Display Name?

rbw87 commented 3 years ago

Hi!

I think I have been mistaken in my analysis. The special characters are not the problem (they were in the body); it is with the default incident template we’re using apparently. Only one mail will be imported. The errors come from the second email onwards.

The generic incident template works fine, but the one we’ve been using with the MS exchange connector does not work. It appears to be related to having an analyst comment in the incident template used for processing new emails. I created a new template with the same values as the previous one, but without the comment. This works fine.

Completely unrelated to the opened issue, I do get this error every interval: The address/SCSM Run As Account used to sign into 365 is not a valid email address and is currently entered as @. This will prevent a successfull connection. To fix this, go to the Run As account in SCSM and for the username enter it as an email address like @.**@.>

This should not occur because I have not configured the connector to use 365: @.***D762DC.5EBE3590]

I would say that the if statement under #validate the Run As Account format to ensure it is an email address Should fall within the if ($UseExchangeOnline) statement.

Thank you for your quick reply!

Robin

AdhocAdam commented 3 years ago

The generic incident template works fine, but the one we’ve been using with the MS exchange connector does not work.

Correct. Per setup instructions you must use custom templates.

Completely unrelated to the opened issue, I do get this error every interval:

It's only now that I'm realizing that the logging message should probably read "used to sign into Exchange" and not "used to sign into 365". Since it's Exchange (not necessarily 365 specifically) that wants the username to be entered like an email to perform authentication. This is similar to the initial configuration of the original Exchange Connector. But something tells me you have it entered like domain\username in which case the auth is successful and thus the error seems out of place? I think you may have attached a screenshot but GitHub's email connector seems to have an issue processing those.

rbw87 commented 3 years ago

I did use a custom template, but it will fail when there’s an analyst comment stored in the template. I don’t have an issue any more as the production template has no analyst comment in it and recreating the template without the analyst comment added is working as expected!

I do have domain\username indeed and this is working fine.

AdhocAdam commented 3 years ago

I did use a custom template, but it will fail when there’s an analyst comment stored in the template. I don’t have an issue any more as the production template has no analyst comment in it and recreating the template without the analyst comment added is working as expected!

OH that's right! That's because of the nature of SCSM Relationships. A template with an Action Log Entry has a unique GUID, so an attempt to re-use it would fail. See here.

I do have domain\username indeed and this is working fine.

Appreciate the confirmation. The next release is on the very immediate horizon, so let me see what I can do to get this in.

Thanks for reporting and using the connector!

AdhocAdam commented 3 years ago

Completed on #308. Will ship with next release via #296