How to send Email Notification to the users through code

Hi Guys,

Need your help !

D365 version 8.1

I have to send the email to users with some condition through code.

please suggest me your valuable input.

what are the setup i need and what is the code that i need to write.

Thanks in Advance.

Look at SysMailerFactory class. You can also find details in a blog post I wrote a few years ago: How to send emails from code in AX 7.

Hi Martin thanks for the quick response.

I followed your blog but i’m getting some exception on this line

SysMailerFactory :: getNonInteractiveMailer ( ) . sendNonInteractive ( message ) ;

Email Parameter Setting are :

pastedimage1549697299775v4.png

Do you have a locally running SMTP server listening on port 25? If not, the fact that the connection fails (if there is nothing to connect to) sounds like the expected behavior to me.

Thanks martin,

In that case, let me check with concern person.

Note that I used a local smtp4dev server just for testing purposes. If you want to do the same thing, download and run smtp4dev.

Obviously you can also use a real email server, but they you need different configuration.

Thank you so much Martin !!!

It is working fine for me now.

thank you once again .