Automation - Send an email with file attached

Hello,

I want to have an automation that send me an email but with a file attached.

It’s working well with images, but with a file it’s not working, I have only the message, but no file attached.

This works
- id: send_mqt_file
alias: Send MQT Humidity History
trigger:
- entity_id: binary_sensor.router_alive
from: ‘off’
platform: state
to: ‘on’
condition: []
action:
data:
data:
images:
- /config/1.png
- /config/2.png
message: Last Sensors info
title: Last Sensors info
service: notify.notifier_send_humidity_history

This is not working (email sent, but no file attached

  - id: send_mqt_file
    alias: Send MQT Humidity History
    trigger:
    - entity_id: binary_sensor.router_alive
      from: 'off'
      platform: state
      to: 'on'
    condition: []
    action:
      data:
        data:
          file: "/config/mqtt_data"
        message: Last Sensors info
        title: Last Sensors info
      service: notify.notifier_send_humidity_history

How can I solve it ?
Thank you

Are you sure the data: object uses file: ?
The examples only use images: and html:

EDIT: I just looked at the code. I think only text images & html are permitted.

To better assist we need to see the notification configuration for notifier_send_humidity_history with personal secrets redacted, of course.

notify:
  - name: notifier_send_humidity_history
    platform: smtp
    server: smtp.gmail.com
    port: 587
    timeout: 15
    sender: MYEMAILADDRESS
    encryption: starttls
    username: MYEMAILADDRESS
    password: MYPASSWORD
    recipient:
      - TO_EMAIL
    sender_name: "A NAME"
    debug: True

I think also that file is not supported, I took a look in the code also.
But I was not sure.
Do you have another solution ?

Thank you

File Sensor?

I use an almost identical routine myself here flawlessly. I can only suggest you check the file names again carefully. (also: I don’t use and quotes in the file: xxx on mine)

Hi,

Thank you, I will try without quote.

Could you share your code that I can take a look and find my error.

To be honest, I don’t understand exactly how File Sensor works. But I think it take the last line of a file, so it’s not hat I search now.

If I can’t solve it I will use GitHub to send the file on it.