Advertisement
guyrleech

Get Outlook draft creation & last modified times

Jan 20th, 2023
1,384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 0.72 KB | Software | 0 0
  1. ## Get Outlook draft creation & last modified times
  2.  
  3. $outlook = New-Object -ComObject outlook.application -Verbose:$false
  4.  
  5. $namespace = $outlook.GetNameSpace( 'MAPI' )
  6.  
  7. $draftsFolder = $namespace.GetDefaultFolder( [Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderDrafts )
  8.  
  9. ## show all drafts
  10. $draftsFolder.items|select-object -property subject,creat*,last*
  11.  
  12. ## show only email drafts
  13. $draftsFolder.items | where-object class -eq 43 | select-object -property subject,creat*,last*
  14.  
  15. ## show edit time (warning: can be negative!)
  16. $draftsFolder.items | where-object class -eq 43 | select-object -property subject,creat*,last*,@{n='edit time';e={($_.LastModificationTime - $_.CreationTime).TotalSeconds -as [int]}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement