As indicated in the subject, I am encountering an unusual problem when attempting to send an email with attachments. When I include text in the report printer, I receive an error as outlined below.
The problem in FileMaker directly is that you don’t get a log on what happened.
while it usually just works, we saw Last error be zero even as emails don’t go out or it reporting an error even when emails went out.
With curl functions, you’d at least get a report on what the server said.
Sending emails is a finicky process and FileMaker's Send Mail script step returns next to no information when something goes wrong. The data is likely where the issue lies if you are able to send emails at times and not at other times. Data, here, is all the information that you use in the Send Mail script step, be they in fields or hard-coded in the script step.
Were the two examples using the same code and referencing the same record, save the text in the report printer? If not, the error may not be in the text of the report printer.
Have you tried sending an email with a simplified text of the report printer, say limited to one paragraph? This will definitely point to the text if you are successfully able to send the email.
What I write may seem silly but the devil's in the details. I once had a customer swear his data was okay. He was able to copy and paste a list of emails from Excel to Outlook and send the email without issue. Copying and pasting the same list to FileMaker produced an error in sending email. The issue? There was an invisible character in the list that Outlook was stripping out during the paste operation. FileMaker didn't strip out anything… because its field is a text field, not an email addressing field as in Outlook.
How do I solve this type of problem? I start with a successful Send Mail script run, then test it iteratively by changing only one piece of data between each test. The moment Send Mail fails, I analyze the data change. I often proceed by successive truncation of the data if I can't see an obvious issue. This tells me where, in the data, the issue starts.
Invisible characters are a bane here. How can you see them? A text editor that can output hexadecial code can help. I use BBEdit on Mac OS. Other options for Mac OS and Windows exist.