HSLUtilLib Email Issue

Hi,

New user here (both of the Hamilton Method Editor and of these forums), so apologies if this question has been answered somewhere else. One of the things I’m trying to do in my code is use the “SendEmail” command of the HSLUtilLib library; but whenever I try to run the simulation it gives me the following error:
“Cannot send email. Root cause: “Failure sending mail.” (0x4c - 0xc - 0x0) (0x23 - 0x2 - 0x39)”
From using the GetEmailAddressOfSender and GETSMTPServerHostName commands it seems that there is an email address and SMTP server available for it to use, but I’m a bit stumped as to what else I need to change?

Any help would be greatly appreciated
Thanks
Tarun

2 Likes

@tarun.chapman - The default values for sender address and SMTP server used by the HSLUtilLib email functions are set via the system configuration editor. The same library also has commands that can overwrite these values from default, if desired.

The config editor can be accessed from the method editor and run control toolbars:

image

Or you can launch it directly from the Hamilton Bin folder of your VENUS install:
image

In the system settings section, you will find the email configuration settings:
image

Admittedly, the currently available configuration options are not sufficient for sending emails to/from servers requiring SSL encryption and SMTP port configuration (like gmail), in addition to standard user authentication. However, this will be remedied in VENUS 6, which will allow for more configuration options and should allow for the ‘SendEmail’ command of the HSLUtilLib to function with such servers.

In the meantime, there are workarounds available that use custom libraries to mimic the function of ‘SendEmail’, but which use more parameters for server configuration. If interested I can follow up.

-Nick

3 Likes

Great to hear about the improvements to email sending in VENUS 6, Nick.
Is there a list of back-end/developer improvements in VENUS 6 anywhere? Not the stuff like a reskinned operator UI, but the deep-dive programmatic stuff.
I’ve already signed up for the webinar on the 30th.

2 Likes

Hi Nick,

Thanks for the quick and informative reply. I’ve had a look at the configuration options and they all seem to be as they should but I’m still getting the error; I can only assume that the server I’m trying to send from requires the SSL encryption or something along those lines, which I don’t have a way of fixing.

I hadn’t heard about Venus 6 actually - when is it planned to be released, and will it be compatible with the Hamilton Microlab Star, which is the machine I currently have access to?

And yeah, any custom libraries that could mimic the function but get around the issues I’m having would be greatly appreciated.

Thanks again
Tarun

2 Likes

Check out this post in another thread for more info on the new VENUS:

Ah thats very informative thank you. Provided I do end up being able to use it on my machine, that looks like it has a lot of very useful and QoL features (especially a potential ctrl + z!).

There is no Undo feature for the next release as far as I know, unfortunately. It will be compatible with your STAR platform.

1 Like

Darn, I’ll have to wait for Venus 7 for that. Just out of interest, is there a particular reason it hasn’t been added?
Good to know. I’ll look forwards to getting the chance to play around with the software as soon as I can get my hands on it.

The feature was never developed - I don’t have more insight on it. I can confirm it is planned for future releases though.

In the meantime, Save and Save As often and use the Disable Steps functionality instead of deleting commands in your method. So, you can make a copy of the commands you want to edit, disable the older commands, and when the newer commands look good, you can safely delete the older ones.

1 Like

Hi Tarun,

As you mentioned, it is likely a security setting. Some servers require a different SMTP port as well. 25 is used by default, but some servers require 587 or 465, which may also be contributing to the error.

Below is a link to a custom library that facilitates ending emails via VENUS, through servers requiring various levels of security and encryption. Just paste the extracted folder from the zip into your Library folder.

SendEmail_SMT

Using a Gmail account to send automatic emails is a popular implementation in the VENUS universe, so I am going to demonstrate and example tailored specifically for that. Of course, there are highly varying IT restrictions out there, so your company may require use different email server. In that case, I would google the various server requirements.

Set up a Gmail account and use the following instructions to enable the mailbox to be accessed by third party applications. This will generate the password used for authentication.

https://wpmailsmtp.com/gmail-less-secure-apps/

Example screenshots:
image

If your team standardizes on a shared email account to use use for auto emails, the highlighted variables can be written into a modified version of the library (or pulled from the configuration or a file), to cut down on the number of required parameters. This would result in only needing parameters for recipient, subject and body (which would emulate the Util::SendEmail function).

-Nick

2 Likes

Hi Nick,

Apologies for the delay in getting back to you. I’ve done as you recommended and installed the SendEmail library and tried to set it up as you suggested, however, it simply gives me the error of “message couldn’t be sent”; I’ve tried using the different SMTP server port numbers and it does nothing either. I’m not sure exactly what in the process is going wrong…

Sorry again
Thanks
Tarun

@tarun.chapman - I can’t really provide much further support without a pkg of the method you are using to attempt to have VENUS send emails, however you would need to remove the password using before sharing, which is a grey area at best for supportability.

For the new GMail account you set up for this purpose, did you enable emails to be sent via 3rd party applications, which generates a specific 16 character password to be used through VENUS?

Also, ensure all your parameters for the custom SendEmail function are of type string. Ex “2” instead of 2 for authentication type.

-Nick

Hi Nick,

No worries, you’ve already been incredibly helpful. I did generate the password for venus yes, and all my parameters are set to strings. I’ll keep troubleshooting and see if I can find the root of the issue.

Thanks again
Tarun

1 Like

@tarun.chapman were you able to find the cause of your issue? I’m trying to use Nick’s smt and get a “Message processed OK” in the trace, but nothing is coming through

Hi, sorry to say that I never solved the issue as I was forced to move on to other stuff :frowning: if I do come back to it and find a solution I’ll be sure to let you know, and if you find one then it’d be great to hear it.

I’ve been trying for a while with our IT people but haven’t been able to get there. I note that the hsl passes the parameters to a VBS script that point to some microsoft schema URLs which look like they might be dead, and MS says they’re no longer maintained. I’m able to send emails with C# and python - if I can kludge something together I’ll post it here

Regarding the error message you’re encountering with the “SendEmail” command of the HSLUtilLib library, there are a few potential reasons for this issue. Here are some troubleshooting steps you can follow:

  1. Verify email server settings: Ensure that the SMTP server settings provided in your code are correct. Double-check the SMTP server hostname, port number, and any required authentication credentials (such as username and password). Contact your email service provider or IT department to confirm the correct SMTP server settings.
  2. Check network connectivity: Ensure that the computer running the simulation has an active network connection and can access the SMTP server. Check for any firewall or network restrictions that may be blocking the outgoing email connection. Test the connectivity by manually sending an email from the same computer using a regular email client.
  3. Check email account permissions: Confirm that the email account being used to send the email has the necessary permissions to send messages through the specified SMTP server. Some email providers may require additional configurations or account settings to enable SMTP access.
  4. Test with a different email recipient: Try sending the email to a different recipient or to another email address you have access to. This can help determine if the issue is specific to the recipient’s email server or if it’s a broader issue with the email configuration.
  5. Enable debug logging: Check if the HSLUtilLib library or your code has any options to enable debug logging or detailed error messages. This can provide more information about the specific cause of the failure, such as network errors, authentication issues, or email server responses.

If you’ve gone through these steps and the issue still persists, it’s recommended to consult the documentation or support resources provided by the HSLUtilLib library or contact the library’s support team for further assistance. They will have specific knowledge about the library’s functionalities and can help troubleshoot the issue more effectively.

1 Like