title: Parse email body paragragh in Powershell
body: <p>I am creating a script to parse outlook email body, so that I can get say an (ID number, date, name) after strings <code>ID: xxxxxx Date: xxxxxx Name:xxxxx</code>. I was looking around and could not fine anything that allows me to take the string after a match.</p>
  
  <p>What I manage so far is to query for the email that was send by the specific users from outlook.</p>
  
  <pre><code>    Add-Type -Assembly "Microsoft.Office.Interop.Outlook"
      $Outlook = New-Object -ComObject Outlook.Application
      $namespace = $Outlook.GetNameSpace("MAPI")
      $inbox =                 $namespace.GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderInbox)
      foreach ($items in $inbox.items){if (($items.to -like "*email*") -or ($items.cc -like "*email.add*")){$FindID = $items.body}}
  </code></pre>
  
  <p>Now that I have the email body in the for loop I am wondering how I can parse the content? </p>
  
  <p>In between the paragraphs will be a text something like this</p>
  
  <pre><code>ID: xxxxxxxx
  Name: xxxxxxxxx
  Date Of Birth : xxxxxxxx
  </code></pre>
  
  <p>I did some testing on the below to see if I can add that into the for loop but it seem like I cannot break the paragraphs.</p>
  
  <pre><code>$FindID| ForEach-Object {if (($_ -match 'ID:') -and ($_ -match ' ')){$testID = ($_ -split 'ID: ')[1]}}
  </code></pre>
  
  <p>I get the following results which I cannot get just the ID.</p>
  
  <p>Sample Result when i do $testID</p>
  
  <pre><code>xxxxxxxx
   Name: xxxxxxxxx 
   Date Of Birth : xxxxxxxx
  
   Regards,
   xxxxx xxxxx
   xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  </code></pre>
  
  <p>How do I get just the results I want? I am just struggling at that portion.</p>