How to use custom template for IMAP emails > 32k

I have created an automation using the IMAP integration, to alert me when emails arrive from specified senders with specified text in the Subject. It currently fails to trigger because the emails exceed the maximum size:

WARNING (MainThread) [homeassistant.components.imap.coordinator] Custom imap_content event skipped, size (36029) exceeds the maximal event size (32168), sender: [email protected], subject: Booking received for 15 Dec 2024

I understand that there is a way of working around this by using a custom template - there is an option in the IMAP integration config to specify a “Template to create custom event data”. I have no idea how to do this, however (and my understanding of templates is very sketchy).
Could anyone suggest how I should use this template to allow my automation to process the message?
The automation is defined as follows:

alias: Parking booking email arrives
triggers:
  - event_type: imap_content
    event_data:
      sender: [email protected]
    trigger: event
  - event_type: imap_content
    event_data:
      sender: [email protected]
    trigger: event
conditions:
  - condition: template
    value_template: "{{ 'ooking' in trigger.event.data.subject }}"
actions:
  - action: media_player.play_media
    target:
      entity_id: media_player.bedroom
    data:
      media_content_id: /local/parking-booking.mp3
      media_content_type: music

On its own, the custom event data template option will not solve this issue.

The next step really depends on your needs and use case:

  1. If you don’t need the body text for any of your IMAP sensor’s uses: Uncheck that setting in the configuration flow of your sensor.
  2. If you do need the body text for the sensor’s other uses, but not for this:
    a. Add filters to the current sensor to exclude these senders.
    b. set up a second sensor specifically for these senders that leaves out the body text and uses a more selective search so only these specific senders are used.
  3. If you need body text for this use:
    a. Do everything from #2.
    b. Provide more information about the data you need to retrieve from the body text so we can help you decide which method is best for this use case.

Many thanks for this. In this use case I only need the email subject, so excluding the body text seems to work. However, I would like to add other automation features for these senders which do require the body text. For example, I’d like to try to extract the start and end times of the booking details. To complicate things, these emails seem to be in rich text format - would that make this unfeasible?