Email Metadata – SharePoint Explorer Outlook Add-In
Setup Email Fields in SharePoint
This document details the setup required to capture email metadata with SharePoint Explorer Outlook Add-In.
In order to capture email metadata on SharePoint while saving emails using the “SharePoint Explorer Outlook Add-In” you must create the relevant fields in SharePoint/O365. The fields can be created manually or using PowerShell scripts.
After the fields have been created you will need to add them to relevant content types or directly to document libraries.
Manual Steps
Create Site Columns
-
-
- Navigate to the target SharePoint site, click on the cog wheel (top right side) and click “Site settings” (classic sites) OR “Site information” -> “View all site settings” (modern sites) to access the site settings page
- Under “Web Designer Galleries” click “Site columns”
- Click on the “Create” link to add a new field and use the below values:
- Column Name: EmFrom
- Type: Single line of text
- Group: Select “New group” and specify “Konnect eMail Fields” as the name
- Accept default for all other settings and click “Ok”
- This will create a new site column “EmFrom” under a new group “Konnect eMail Fields”. After the creation you can edit the field and rename it to meet your requirements
- Use the above steps to create additional fields required by the Add-In. Additional fields are specified in the table below with their settings
-
Note: it is important that you use the exact column names specified here at the time of creation – after creation they can be renamed, however other settings should not be altered.
If you have completed the above step:
-
-
- you can skip creating “EmFrom” field from the table below as this has already been done
- when creating additional fields you will need need to select “Existing group” in the Groups settings and select “Konnect eMail Fields” in the drop-down (this was created in the steps above)
-
Column Name | Type | Group | Additional Settings |
---|---|---|---|
EmDate | Date and Time | Konnect eMail Fields | Accept default for all other settings |
EmTo | Multiple lines of text | Konnect eMail Fields |
Specify the type of text to allow = Plain text Accept default for all other settings |
EmFrom | Single line of text | Konnect eMail Fields | Accept default for all other settings |
EmCC | Multiple lines of text | Konnect eMail Fields |
Specify the type of text to allow = Plain text Accept default for all other settings |
EmBCC | Multiple lines of text | Konnect eMail Fields |
Specify the type of text to allow = Plain text Accept default for all other settings |
EmSubject | Single line of text | Konnect eMail Fields |
Accept default for all other settings |
EmBody | Multiple lines of text | Konnect eMail Fields |
Specify the type of text to allow = Plain text Accept default for all other settings |
EmConversationTopic | Single line of text | Konnect eMail Fields |
Accept default for all other settings |
EmConversationIndex | Single line of text | Konnect eMail Fields |
Accept default for all other settings |
EmConversationId | Single line of text | Konnect eMail Fields |
Accept default for all other settings |
EmAttachmentCount | Single line of text | Konnect eMail Fields | Accept default for all other settings |
EmAttachment | Multiple lines of text | Konnect eMail Fields |
Specify the type of text to allow = Plain text Accept default for all other settings |
EmSensitivity | Single line of text | Konnect eMail Fields | Accept default for all other settings |
EmTransferAction | Single line of text | Konnect eMail Fields | Accept default for all other settings |
Add Columns to Content Types
Skip this step if you do NOT use content types on the SharePoint site.
-
-
- Navigate to the target SharePoint site, click on the cog wheel (top right side) and click “Site settings” (classic sites) OR “Site information” -> “View all site settings” (modern sites) to access the site settings page
- Under “Web Designer Galleries” click “Site content types”
- Select the content type that you use and want to add email metadata to
- Scroll to the “Columns” (classic site) or “Site columns” (modern site) section and click “Add from existing site columns” (classic site) OR “Add site column” -> “Add from existing site columns” (modern site)
- Add all “Konnect eMail Fields”:
- Classic site: select “Konnect eMail Fields” in the “Select site columns from” drop-down -> select all fields in the “Available site columns” selection box (use shift+click to select multiple) -> click the “Add” button
- Modern site: select “Konnect eMail Fields” in the “Select site columns from existing category” drop-down -> select fields in the left hand selection box and click the add “>” button (repeat this to add all the Konnect eMail Fields)
- Click the “Save”/”Ok” button
-
Add Columns to Document Library
Skip this step if you have added the Konnect eMail fields to content types directly in the above steps.
-
-
- Navigate to the target SharePoint site, click on the cog wheel (top right side) and click “Site contents” to access the site contents page
- Select the target document library from the list – this is where you will save the emails
- From the document library page, click on the cog wheel (top right side) and click “Library settings” (classic site) OR “Library settings” -> “More library settings” (modern sites) to access the settings page
- Scroll down to the “Columns” section and select “Add from existing site columns”
- Select “Konnect eMail Fields” in the “Select site columns from” drop-down -> Select all fields in the “Available site columns” selection box (use shift+click to select multiple) -> click the “Add” button
- Only applicable if you use content types – if you would like to add the fields to the document library content types then select “Add to all content types”
- Click “Ok”
-
Automated Steps
This option involves using PowerShell and should be executed by someone who is comfortable using scripts and has appropriate access to the SharePoint site.
Note: we strongly recommend that you test these scripts in a development environment before running in production
Create Site Columns
-
-
- Start PowerShell run the below script
-
function Set-SPOKEFields {
param (
[Parameter(Mandatory=$true,Position=1)]
[string[]]$Fields
)
try {
$oFields = Get-PnPField
foreach($field in $Fields) {
$newField = $oFields | where {$_.InternalName -eq $field}
if($newField -ne $NULL) {
Write-host "Site Column $ColumnName already exists!" -f Yellow
}
else
{
if($field -eq "EmDate") {
$displayName = $field -replace "Em","Email "
$guid = Get-FieldID -FieldName $field
$FieldSchema = "
" Add-PnPFieldFromXml -FieldXml $FieldSchema
}
elseif(($field -eq "EmFrom") -or ($field -eq "EmSubject") -or ($field -eq "EmAttachmentCount") -or ($field -eq "EmSensitivity") -or ($field -eq "EmTransferAction") -or ($field -eq "EmConversationTopic") -or ($field -eq "EmConversationIndex") -or ($field -eq "EmConversationId")) {
$displayName = $field -replace "Em","Email "
$guid = Get-FieldID -FieldName $field
$FieldSchema = "
" Add-PnPFieldFromXml -FieldXml $FieldSchema
}
else {
$displayName = $field -replace "Em","Email "
$guid = Get-FieldID -FieldName $field
$FieldSchema = "
" Add-PnPFieldFromXml -FieldXml $FieldSchema
}
Write-host "Site Column Created Successfully!" -ForegroundColor Green
}
}
}
catch [Net.WebException] {
Write-Host $Url " failed to connect to the site" $_.Exception.Message.ToString() -ForegroundColor Red
}
}
function Get-FieldID {
param (
[Parameter(Mandatory=$true,Position=1)]
[string]$FieldName
)
$guid = switch ($FieldName) {
"EmDate" {"b1f75b72-daed-4963-a8b0-99b598205eb0"; break}
"EmTo" {"1abc7201-880b-4802-912a-32669f4cda6e"; break}
"EmFrom" {"5797777c-2cfe-4b9e-8638-298c36f1a3d4"; break}
"EmCC" {"31399494-ca4d-4da9-bdb6-f452e56c4b12"; break}
"EmBCC" {"88511fc1-04be-4a08-bc4d-122c43541447"; break}
"EmSubject" {"2dde6173-4ffc-430d-a8bd-97de57cb432b"; break}
"EmBody" {"c6c37ebd-bae0-4c89-b6ef-5d93dd917d8f"; break}
"EmConversationTopic" {"0443e054-e14a-40c1-89cc-fcd1e63d6286"; break}
"EmConversationIndex" {"9bf6a98c-bae4-40d5-ad9c-722870d25e6d"; break}
"EmConversationId" {"59e4db4e-f328-4028-bade-95d33106e8bc"; break}
"EmAttachmentCount" {"d48beaf0-2cac-4628-8dd4-924129914886"; break}
"EmAttachment" {"8bd27213-794b-40ac-8542-277cdb016985"; break}
"EmSensitivity" {"b2ca25c8-6704-4591-b363-c5fd6dbd45b9"; break}
"EmTransferAction" {"ba53ff39-2fc3-4b20-8a1e-2005a5e580d2"; break}
"EmURLs" {"a458d01f-2bd7-4776-9f49-3b3180b446d5"; break}
"EmKeywords" {"bc7d058f-ead1-41d2-83a9-a7f7178d6cc8"; break}
default {""; break}
}
return $guid
}
function Add-FieldToLists {
param (
[Parameter(Mandatory=$true,Position=1)]
[string[]]$Fields
)
$docLibraries = Get-PnPList | Where-Object {$_.BaseTemplate -eq 101 -and $_.Hidden -eq $false}
foreach($docLibrary in $docLibraries) {
$confirm = Read-Host "Do you want to add fields to " $docLibrary.Title "? (y/n)"
if($confirm -eq "y") {
foreach($field in $Fields) {
$oFields = Get-PnPField -List $docLibrary.Title
$oField = $oFields | where {$_.InternalName -eq $field}
if($oField -ne $NULL) {
Write-host "Field $ColumnName already exists!" -f Yellow
}
else {
Write-host "Adding Fields to "$docLibrary.Title -f Yellow
Add-PnPField -List $docLibrary.Title -Field $field
Write-host "Fields added to "$docLibrary.Title"!" -ForegroundColor Green
}
}
}
}
}
function Add-FieldToContentTypes {
param (
[Parameter(Mandatory=$true,Position=1)]
[string[]]$Fields,
[Parameter(Mandatory=$true,Position=2)]
[string[]]$ContentTypes
)
foreach($ContentType in $ContentTypes) {
Get-PnPContentType -Identity $ContentType
$confirm = Read-Host "Do you want to add fields to " $ContentType "? (y/n)"
if($confirm -eq "y") {
foreach($field in $Fields) {
$oFields = Get-PnPField -List $docLibrary.Title
$oField = $oFields | where {$_.InternalName -eq $field}
if($oField -ne $NULL) {
Write-host "Field $ColumnName already exists!" -f Yellow
}
else {
Write-host "Adding Fields to "$docLibrary.Title -f Yellow
Add-PnPField -List $docLibrary.Title -Field $field
Write-host "Fields added to "$docLibrary.Title"!" -ForegroundColor Green
}
}
}
}
}
Install-PackageProvider -Name NuGet -Force -Scope CurrentUser
Install-Module PnP.PowerShell -RequiredVersion 1.12.0 -Scope CurrentUser -Verbose -Force
Import-Module PnP.PowerShell -Scope Local -WarningAction SilentlyContinue
# Insert URL of the SharePoint site collection (Root Site)
$Url = "https://tenent-name.sharepoint.com/sites/site-name"
$fields = "EmDate","EmTo","EmFrom","EmCC","EmSubject","EmBody","EmConversationTopic","EmConversationIndex","EmConversationId","EmAttachmentCount","EmAttachment","EmBCC","EmSensitivity","EmTransferAction"
$contentTypes = "Document","Document Set"
Connect-PnPOnline -Url $Url -Interactive
Set-SPOKEFields -Fields $fields
Add Columns to Content Types
Skip this step if you do NOT use content types on the SharePoint site.
-
-
- Update the “$contentTypes” variable with the names of content types and run the below code
-
$contentTypes = "Document","Email Document"
Add-FieldToContentTypes -Field $fields -ContentTypes $contentTypes
Add Columns to Document Library
Skip this step if you have added the Konnect eMail fields to content types directly in the above steps.
-
-
- Run the below code
-
Add-FieldToLists -Field $fields