title: Find and extract text in email with Python
body: <p>My goal is to get a random login code from an email.</p>
  <p>I have the email but I don't know how to extract the login code from the email.</p>
  <p>The login code is the only text in bold within the email and would be made up of random numbers and letters.</p>
  <p>How do I find the code in the email to use elsewhere in my script?</p>
  <p>This is the code to get the email.</p>
  <pre><code>   import win32com.client
      from datetime import datetime, timedelta
      
      def get_email_code():
          outlook = win32com.client.Dispatch('outlook.application')
          mapi = outlook.GetNamespace(&quot;MAPI&quot;)
          inbox = mapi.GetDefaultFolder(6)
          emails = inbox.Items
          receive_time = datetime.now() - timedelta(minutes=1)
          receive_time = received_dt.strftime('%m/%d/%Y %H:%M %p')
          emails = messages.Restrict(&quot;[ReceivedTime] &gt;= '&quot; + received_dt + &quot;'&quot;)
          emails = messages.Restrict(&quot;[SenderEmailAddress] = 'test@test.com'&quot;)
          emails = messages.Restrict(&quot;[Subject] = 'test'&quot;)
          codeEmail = emails[0]
  </code></pre>
  <p>Thanks in advance!</p>