<{{Subtitle_Weight}} class="prominent-subhead {{Show_Subtitle}}"> {{Header_Subtitle}}

Unable to access the Environment Library:The connection string is invalid: [Mail Server]. Index was outside the bounds of the array.

This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice. This article is not considered official documentation for K2 software and is provided "as is" with no warranties.


Unable to access the Environment Library in the K2 Management site and the SmartObjects/Views/Forms in K2 Designer due to the error below:

"The connection string is invalid: [Mail Server].
Index was outside the bounds of the array."


When you click on the Environment Library node, you will see this error:


When opening any SmartObject, View or Form in K2 Designer, the same error appears:


Troubleshooting Steps

The cause of the error is due to the Mail Server environment library fields' field type being incorrectly set to 'Exchange Server' instead of 'Mail Server'.


Please follow the steps below to resolve the issue:

1. Make a backup of your K2 database, in case of a need to roll back.

2. Run the following query and note down the value in 'TypeId'.

Select * from [K2].[Environment].[FieldType]

where FriendlyName = 'Mail Server'

3. Run the following query to update 'TypeId' to the correct value, which is the Type Id of the Mail Server field. 

Update [K2].[Environment].[Field]

set TypeId = '<Replace with TypeId from Step 2>'

where FieldName = 'Mail Server'

If you need any assistance in performing the steps above, please do not hesitate to contact K2 Technical Support.