Ignition Edge sends emails but no attachments

Similar setup here - nothing against you personally, it's just that each time I work through a "person got a mountain of code from an LLM" post and try to guide them through all the things it did wrong makes me feel like Sisyphus.

Top level notes:

  • You should only rarely need to import anything in small Ignition scripts. Any imports you do use, you should be judicious about.
    • You should never import system or anything from system.
    • You should never use Jython's datetime library.
    • You should (almost) never have to import core Java classes like Date and String
  • Defining an email_historian_data_report() function only to call it in the same file is totally pointless. If you're going to define this as a function, it should be in the project library, and it should accept useful parameters (potentially with default values).
  • while loops are rarer than imports and should also almost never be used.
  • system.gui.warningBox is a Vision only function that precludes this script from working in Perspective or being called from anywhere else in Ignition.
  • Logging statements should be called with infof variants to do string formatting lazily, for the sake of performance.
  • There's no need to import array or coerce the Jython string into a Java string in order to pass it to the attachment parameter
  • A try/catch Exception around the whole block is only going to cause you grief troubleshooting, as it won't catch Java exceptions and it throws away the stacktrace, the most useful element for troubleshooting.
10 Likes