question

Vinay S avatar image
0 Likes"
Vinay S asked Ben Wilson commented

Email sending through the flexsim custom code

Please explain it is possible to send the email from Flexscript custom code or any other way

FlexSim 23.1.0
process flow
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Ben Wilson avatar image
1 Like"
Ben Wilson answered Ben Wilson commented

Hi @Vinay S,

FlexSim itself does not have email features built in. Due to the extensible nature of FlexSim, you *could* create your own DLL with that functionality. But probably that is not the best use of your time when many 3rd party services or open source email servers already exist that can do the email part for you.

The easiest would be for you to use OPC-UA (as described in Jason's answer) or FlexSim's HTTP API to contact an external server that would send the email on your behalf.

Using FlexSim to send an HTTP request you could send your request to a simple web server that you host that also includes email functionality. It could be a Node.js email server, or a PHP email server, or whatever language or platform you care to set up.

Or there is a chance that your email provider has a HTTP API you can access directly. If you do an Internet search for "send email by http request <service name>" you will get resources that could help you tailor your HTTP request. So, for example "send email by http request gmail" or "send email by http request exchange", etc.


· 9
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Vinay S avatar image Vinay S commented ·

Thank you,

Can you share a example model ?

0 Likes 0 ·
Ben Wilson avatar image Ben Wilson ♦♦ Vinay S commented ·

@Shibananda C2,

This wouldn't be something you can do in a model. The model would just send an HTTP request somewhere else.

Your real work will be at the request's target destination. You'll need to configure some server to accept the HTTP request and kick off an email. Or find some email service that will do that for you with access to an HTTP API. That is beyond the scope of this FlexSim support forum. Google and StackOverflow will be your friends in solving that problem.

As for support on the FlexSim side of things, you can find examples of using FlexSim's HTTP API in this community. Here are a few:

1 Like 1 ·
Vinay S avatar image Vinay S Ben Wilson ♦♦ commented ·
Thank you @Ben Wilson , it worked, I setup a PHP server to send mail and using this server url in HTTP API to trigger mail.
0 Likes 0 ·
Show more comments
Joerg Vogel avatar image Joerg Vogel Vinay S commented ·

@Vinay S, please look for it yourself in the internet.

I tried it with “c++ send mail” and got several links in GitHub and stackoverflow.

0 Likes 0 ·
Vinay S avatar image Vinay S Joerg Vogel commented ·

Thank you, good idea.

Can you share a model, if you have ?

0 Likes 0 ·
Show more comments
Jason Lightfoot avatar image
1 Like"
Jason Lightfoot answered Vinay S commented

Have you considered using Node-Red to send the email after a web/socket communication from FlexSim? Or have FlexSIm write a text file or database record and detect that. If you have the emulation license you could use OPC-UA to Node-Red.

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Vinay S avatar image Vinay S commented ·
can you share the example model for this
0 Likes 0 ·