So I have found the following ways after much trial and error this morning:
Solution 1 - Create URL using the ID from email URL
Firstly for this to work you need to turn off conversation mode in OWA, you can do this by clicking the cog in the top right whilst in your mailbox then under "Conversation View" set this to off. (This is so the URL when you have an email selected will give you the message/item ID and not the conversation ID.)
Then select the email that you want to create a link to, the URL will look like below but with [MESSAGE_ID]
showing the full message ID in a URL encoded format.
https://outlook.office.com/mail/inbox/id/[MESSAGE_ID]
Copy the full [MESSAGE_ID]
and insert it as shown in the following URL:
https://outlook.office.com/owa/?ItemID=[MESSAGE_ID]&viewmodel=ReadMessageItem&path=&exvsurl=1
When opening this link it will take you directly to the email.
Please see the below powershell script that will open a form, you insert the URL copied from the browser into the 1st text box and click "Convert", this will then return the URL that will point to the email in O365 and clear the 1st field so that its quick to convert a few in a row, also the window should stay top most.
This will still require the conversion mode to be set to off as mentioned in the 1st paragraph. I would like to add that this has been very quickly knocked up using PoshGUI editor and anchors etc have not been set so expanding the window may not have the desired effect.
Function Convert-URL{
Param(
[String]$O365_URL
)
$inputURL = $O365_URL
$returnURL = "https://outlook.office.com/owa/?ItemID=" + ($inputURL | Split-Path -Leaf) + "&viewmodel=ReadMessageItem&path=&exvsurl=1"
$returnURL
}
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()
$Form = New-Object system.Windows.Forms.Form
$Form.ClientSize = '735,80'
$Form.text = "O365 URL Convertor"
$Form.TopMost = $true
$TextBox1 = New-Object system.Windows.Forms.TextBox
$TextBox1.multiline = $false
$TextBox1.width = 446
$TextBox1.height = 20
$TextBox1.location = New-Object System.Drawing.Point(150,5)
$TextBox1.Font = 'Microsoft Sans Serif,10'
$Label1 = New-Object system.Windows.Forms.Label
$Label1.text = "Insert URL"
$Label1.AutoSize = $true
$Label1.width = 25
$Label1.height = 10
$Label1.location = New-Object System.Drawing.Point(21,12)
$Label1.Font = 'Microsoft Sans Serif,10'
$Label2 = New-Object system.Windows.Forms.Label
$Label2.text = "Returned URL"
$Label2.AutoSize = $true
$Label2.width = 25
$Label2.height = 10
$Label2.location = New-Object System.Drawing.Point(21,38)
$Label2.Font = 'Microsoft Sans Serif,10'
$TextBox2 = New-Object system.Windows.Forms.TextBox
$TextBox2.multiline = $false
$TextBox2.width = 446
$TextBox2.height = 20
$TextBox2.location = New-Object System.Drawing.Point(150,34)
$TextBox2.Font = 'Microsoft Sans Serif,10'
$Button1 = New-Object system.Windows.Forms.Button
$Button1.text = "Convert"
$Button1.width = 100
$Button1.height = 30
$Button1.location = New-Object System.Drawing.Point(619,9)
$Button1.Font = 'Microsoft Sans Serif,10'
$Form.controls.AddRange(@($TextBox1,$Label1,$Label2,$TextBox2,$Button1))
$Button1.Add_Click({$TextBox2.Text = Convert-URL -O365_URL $TextBox1.Text; $TextBox1.Text = "";})
$Form.ShowDialog()
Solution 2 - Office 365 Graph API
The property "Weblink" is returned from the "Get-Message" API request.
Please see the below sources that show this property:
Under the response you will see the "weblink" property, the URL is constructed the same as the solution above.
https://docs.microsoft.com/en-us/graph/api/message-get?view=graph-rest-1.0&tabs=http
The following link is to the graph explorer, of which you can sign in and interact with the graph API to see a working example, after signing in click "Get My Mail" in the left pane". This will return an API response in the bottom right of all you emails and you will the weblink returned for each email in this window.
https://developer.microsoft.com/en-us/graph/graph-explorer
However whilst the above is not very practical to use manually, this is where I would start to make a script / programme to retrieve the URL.
Cheers for comprehensive answer. Will check it out over the next couple of days. – Nick Riches – 2020-02-01T00:19:46.913
Many thanks. I've tested the first solution which works very well. I don't have the level of technical ability to understand the second. I just wish there was a way to address this without switching off conversation mode, which I find very useful, but clearly this is an issue related to the way Microsoft has designed its webmail. – Nick Riches – 2020-02-01T12:28:51.090
P.S. there is a Chrome extension called "URL editor" which could do some of the heavy lifting. – Nick Riches – 2020-02-01T12:36:50.020