IT Monkey:   Click Here to Help Me Build the Agenda for Upcoming Cireson Webinars!

Error with processing incoming mail

Stephane_BouillonStephane_Bouillon Customer Adept IT Monkey ✭✭
Hi, i'm finding a lot of information messages in the event log with the following:


Exchange Connector: Unable to process mail item. Subject="[IN94670] - [RESOLVED] - Administration", Error Message=The key value of an object cannot be changed.


The result is that the Template is not applied to the incident, and that the mail isn't processed correctly. Any ideas what might be causing this ?

Stephane

Best Answers

  • Stephane_BouillonStephane_Bouillon Customer Adept IT Monkey ✭✭
    Accepted Answer
    Indeed, this involves mails and an extension of the incident class. Strangely, not all mails are discarded. Is there a workaround ? I haven't heard about the SMLets exchange connector. Would this solve my issue ?
  • Adam_DzyackyAdam_Dzyacky Customer Contributor Monkey ✭✭✭✭✭
    edited February 8 Accepted Answer
    When it comes to SMA, you'll need to create a schedule for every 5 minute interval of the day. To say the least, it's rather time consuming through the GUI. But as you might guess, this is something you can script into existence using the SMA PowerShell module.

    One such example can be found here. Something tells me @Tom_Hendricks probably did something similar?

Answers

  • Stephane_BouillonStephane_Bouillon Customer Adept IT Monkey ✭✭
    Accepted Answer
    Indeed, this involves mails and an extension of the incident class. Strangely, not all mails are discarded. Is there a workaround ? I haven't heard about the SMLets exchange connector. Would this solve my issue ?
  • Adam_DzyackyAdam_Dzyacky Customer Contributor Monkey ✭✭✭✭✭
    edited February 5
    Strangely, not all mails are discarded.
    I forgot to mention that part as well - there does not appear to be a known pattern or reasoning as to why some work and some don't. The closest I got (but again, can't definitively prove) was the Incident/Runbook issue cited above. So as far as a workaround goes, I'm not aware of one because I'm not entirely sure the issue is fully understood given the closed source nature of the stock Exchange Connector.

    The SMLets Exchange Connector doesn't suffer from the issue because it's only updating a very specific subset of fields on a Work Item (as opposed to a template which is a blanket update of sorts and would clearly be custom across customers). As such, it also means that it isn't negatively impacted by any number of class extensions that could have been performed in an environment.

    Apart from the link above which inevitably would lead you over to my GitHub. The most recent article on it is Cireson's adoption of it.
  • Stephane_BouillonStephane_Bouillon Customer Adept IT Monkey ✭✭
    Great, I'll check it out.
    Thanks Adam
  • Stephane_BouillonStephane_Bouillon Customer Adept IT Monkey ✭✭
    I have experience with PowerShell & Cireson & SMA. However, I have no idea where to start using the tool you shared on GitHub. Is there a setup guide ?
  • Adam_DzyackyAdam_Dzyacky Customer Contributor Monkey ✭✭✭✭✭
    Yup. It's on the Wiki here -
    https://github.com/AdhocAdam/smletsexchangeconnector/wiki/Configuration-Examples

    As far as how to configure the script/runbook, we've gone to a pretty detailed length of listing out what every single variable/configuration does inline of the script. Just open up smletsExchangeConnector.ps1 and past the change notes you'll see what I'm referring too.

    Feel free to ping me back with any other questions you may have.
  • Stephane_BouillonStephane_Bouillon Customer Adept IT Monkey ✭✭
    I've started testing, but I'm hitting a roadblock when trying to Bind to the exchangeservice:

    $scsmMGMTServer = "hqscsmms01"
    $scsmMGMTCreds = $null
    $exchangeAuthenticationType = "impersonation"
    $workflowEmailAddress = "[email protected]"
    $username = "scsm_workflow"
    $password = "xxxxxxxxx"
    $domain = "multi.be"
    $UseAutodiscover = $false
    $ExchangeEndpoint = "https://owa.multipharma.be/EWS/Exchange.asmx"

    $inboxFolderName = [Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox
    $inboxFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($exchangeService,$inboxFolderName)
    This last instruction fails with the following error

    Exception calling "Bind" with "2" argument(s): "When making a request as an account that does not have a mailbox, you must specify the mailbox primary SMTP address for any distinguished folder Ids."
    At D:\Processes\Config\smletsExchangeConnector.ps1:2772 char:1
    + $inboxFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($ex ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : ServiceResponseException

    I based myself on the settings in our existing Exchange Connector:



    I must be overlooking Something obvious ?

    Stephane
  • Adam_DzyackyAdam_Dzyacky Customer Contributor Monkey ✭✭✭✭✭
    edited February 7
    From the screenshots I can clearly see you're using Impersonation, but the first thing that comes to mind is that while you're testing could you try starting your PowerShell editor of choice as your workflow account and then attempting to execute? Curious to see if you get the same error.
  • Stephane_BouillonStephane_Bouillon Customer Adept IT Monkey ✭✭
    Yes still the same error when Run As the Windows Powershell ISE as scsm_workflow
  • Stephane_BouillonStephane_Bouillon Customer Adept IT Monkey ✭✭
    The mailbox is a shared mailbox. Is that an issue ?
  • Adam_DzyackyAdam_Dzyacky Customer Contributor Monkey ✭✭✭✭✭
    Shared mailbox. Is this on office 365?
  • Stephane_BouillonStephane_Bouillon Customer Adept IT Monkey ✭✭
    No, local exchange mailbox. We do have O365 in our organisation but this is a technical mailbox.
  • Stephane_BouillonStephane_Bouillon Customer Adept IT Monkey ✭✭
    I checked this https://docs.microsoft.com/en-us/exchange/client-developer/exchange-web-services/delegate-access-and-ews-in-exchange#bk_explicitewsma

    and then tried to update the code to use an FolderId instead, but now get another error:

    $inboxFolderName = [Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox
    $inboxfolderId = New-Object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox,$workflowEmailAddress)
    #$inboxFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($exchangeService, $inboxFolderName)
    $inboxFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($exchangeService, $inboxFolderId)
    The error I get is

    Exception calling "Bind" with "2" argument(s): "Connection did not succeed. Try again later."
    At D:\Processes\Config\smletsExchangeConnector.ps1:2774 char:1
    + $inboxFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($ex ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : ServiceResponseException
  • Stephane_BouillonStephane_Bouillon Customer Adept IT Monkey ✭✭
    Hi, I made a stupid typo, "impersonate" instead of "impersonation"
    But when using a shared mailbox, one needs to pass a FolderId parameter to the Bind
    I can now retrieve the mails, thanks for your assistance Adam !
  • Adam_DzyackyAdam_Dzyacky Customer Contributor Monkey ✭✭✭✭✭
    edited February 8
    Just getting back to this, excellent to hear you've got this sorted out. That said, you aren't the first to make this typo. Rest assured "something" is on its way for the next release to prevent such an event from occurring.

    I'll log the Shared mailbox issue you cited and investigate.
  • Stephane_BouillonStephane_Bouillon Customer Adept IT Monkey ✭✭
    So I have it up and running with an SMA Script Runbook.Thanks again for your time and effort. I have a very basic need at this moment, but looking at all the bells and whisles you provided in the tool, I think I'm not yet done optimizing our processes ...

    What I need to do next is have the script run at a regular interval eg. every 5 minutes. What is the best way of achieving this ?

    Stephane
  • Adam_DzyackyAdam_Dzyacky Customer Contributor Monkey ✭✭✭✭✭
    edited February 8 Accepted Answer
    When it comes to SMA, you'll need to create a schedule for every 5 minute interval of the day. To say the least, it's rather time consuming through the GUI. But as you might guess, this is something you can script into existence using the SMA PowerShell module.

    One such example can be found here. Something tells me @Tom_Hendricks probably did something similar?
  • Tom_HendricksTom_Hendricks Customer Super IT Monkey ✭✭✭✭✭
    I agree with everything Adam says above, but want to give an alternative too.  I followed the article above in my dev environment a while back, but having that many schedules really clogged up SMA.  There is nothing technically wrong with it, but I did not care for it personally, and also did not want to alter that many objects (via script or UI) if I had more scripts to run at that frequency or less.  It just starts to get hard to follow for someone who might be seeing it for the first time while providing support at 3am on a weekend, for example. Your situation may vary, of course.

    In my case, I wrote a simple "trigger" script that invokes the runbook, and then ran that script via a Win task scheduler on the schedule I wanted.  That worked very well for quite a while, but having to script for times when a job would hang and I did not want to trigger another (an advantage over SMA schedules) caused this to evolve even further.  But it started with a 2-line script run by task scheduler.

    Creating schedules outside SMA can seem counterintuitive but the results have been very good.

    If you also run old-school Orchestrator, you could use it instead of task scheduler.  It is vastly superior to SMA in terms of scheduling and security granularity, even after all these years.  IMO, there is no shame in using the best tools to get the best result, even if you believe (like I do) that you shouldn't have to do it in this way.  I decided against this approach, but only because our support teams are more familiar with task scheduler.
  • Stephane_BouillonStephane_Bouillon Customer Adept IT Monkey ✭✭
    Stupid suggestion maybe: what if I just kick it off once in the morning at 8am and let the script run throughout the day with a 5min wait between every cycle within the script itself ? It could then just stop itself around 6pm, no need to run through the night. Would that be a wrong way of doing ?
Sign In or Register to comment.