E-Mail Message Not Sending As Notification

I created a notification system to play anytime my son emails me from his school email address. I can play the body of the message through the speakers in my house, but I receive an ‘API Error’ when I try to pass msg.payload into a Notification.

Any ideas why?

[{""72a884fa2ac45b4e","type":"e-mail in","z":"d4f9ac9d.d5ff08","name":"Matthew E-Mail","protocol":"IMAP","server":"imap.gmail.com","useSSL":true,"autotls":"never","port":"993","box":"INBOX","disposition":"None","criteria":"UNSEEN","repeat":"200","fetch":"auto","inputs":0,"x":100,"y":1520,"wires":[["182bc5349cac4152"]]},{"id":"182bc5349cac4152","type":"switch","z":"d4f9ac9d.d5ff08","name":"","property":"from","propertyType":"msg","rules":[{"t":"cont","v":"[email protected]","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":290,"y":1520,"wires":[["db6bfcf6ab8f2f03","709f957c51bf6c60"]]},{"id":"709f957c51bf6c60","type":"ttsultimate","z":"d4f9ac9d.d5ff08","name":"","voice":"en-US","ssml":false,"sonosipaddress":"192.168.7.229","sonosvolume":"40","sonoshailing":"Hailing_Hailing.mp3","config":"4fb4091b8b8528dc","property":"payload","propertyType":{},"rules":[{"host":"192.168.7.224"},{"host":"192.168.7.47"},{"host":"192.168.7.206"},{"host":"192.168.7.135"}],"x":530,"y":1480,"wires":[[],[]]},{"id":"a372a3be2824c59b","type":"api-call-service","z":"d4f9ac9d.d5ff08","name":"Justin's iPhone","server":"8efa78ba.f10338","version":3,"debugenabled":false,"service_domain":"notify","service":"mobile_app_iphone","entityId":"","data":"{\"message\":\"{{email}}\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":640,"y":1560,"wires":[[]]},{"id":"7b6787b5da0d9c6c","type":"api-call-service","z":"d4f9ac9d.d5ff08","name":"LaMetric","server":"8efa78ba.f10338","version":3,"debugenabled":false,"service_domain":"notify","service":"office_lametric","entityId":"","data":"{\"message\":\"Matthew email sent an email saying {{email}} \",\"data\":{\"sound\":\"notification\",\"icon\":\"2659\",\"cycles\":2,\"priority\":\"info\",\"icon_type\":\"none\"}}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":620,"y":1600,"wires":[[]]},{"id":"db6bfcf6ab8f2f03","type":"function","z":"d4f9ac9d.d5ff08","name":"","func":"msg.email = \"Matthew sent an email saying\" +msg.payload\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":1560,"wires":[["a372a3be2824c59b","7b6787b5da0d9c6c"]]},{"id":"4fb4091b8b8528dc","type":"ttsultimate-config","name":"Config","noderedipaddress":"192.168.7.101","noderedport":"1980","purgediratrestart":"leave","ttsservice":"googletranslate"},{"id":"8efa78ba.f10338","type":"server","name":"Home Assistant","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

First off you have your son’s email address exposed in the above code. I dont see the need for the function node. Just pass the variable in the service call.

Instead of this

{"message":"{{email}}"}

use

"message": "Matthew sent an email saying {{payload}} ",

I changed the node for privacy-sake. Your solution was my prior solution and that did not work either.

Is there a url in the message body? If so use {{{payload}}}

Here is the entire msg

I cut out the email address…

Also, had another question related to the same flow. The way the email works is that the message replays every 200 seconds as a TTS until it is read. Can you think of a clever way to stop this after X number to repeats?

Did you try it with the triple mustache? It may be from the email address.

Does the information you need always come through the payload position? Do you need anything from html or the header? If not use a change node and set it to delete msg.header and msg.html