Unable to send a simple email from a MID Server Script Include in my PDI

Ravi Kumar Pisu
Tera Expert

Hi,

 

My team is trying for a requirement to send an email from a MID Server. For this, we have MID Server setup ready in our PDI and the email config is also ready. We would like to add the code in MID Server Script Include and create a Payload on the ECC queue to give a shot on this. But we are unable to send the email using below snippet.

===========

var SendEmail = Class.create();
SendEmail.prototype = {
  initialize: function() {},
  sendEmail: function() {
//var emailGR = new GlideRecord('sys_email');
var emailGR=new GlideAjax("sys_email");
emailGR.initialize();
emailGR.type = 'send-ready';
emailGR.subject = 'Hello';
emailGR.body = 'How are you??';
emailGR.recipients = 'ram@yahoo.com';
emailGR.insert();  
gs.eventQueue('email.send', emailGR, emailGR.recipients, emailGR.subject, emailGR.body);
  },
  type: 'SendEmail'
};
===========
Attached the err details from the ECC queue perspective and no clue from them.
Any inputs/help is appreciated in this regards. If any alternative ways to send email is also fine for us.
 
Thanks,
Ravi Kumar.
4 REPLIES 4

AnveshKumar M
Tera Sage
Tera Sage

Hi @Ravi Kumar Pisu 

Check this answer once.

 

https://www.servicenow.com/community/now-platform-forum/how-to-connect-email-through-midserver/m-p/1...

 

Please mark my answer helpful and accept as solution if it helped you 👍

Thanks,
Anvesh

Hi Anvesh,

I have seen this article but it didn't help me much. 

Thank you.

AndersBGS
Tera Patron
Tera Patron

Hi @Ravi Kumar Pisu ,

 

Have you seen this post in relation to emails from PDI: Changes to sending emails from PDIs (servicenow.com)

AndersBGS_0-1699267205310.png

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Best regards

Anders 

 

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

Hi Anders, 

I have enabled the sending email feature in my PDI since Tokyo and I am able to send the emails by running the Background Scripts option manually. For this particular scenario, I am unable to do that since I doubt on the MID Server script include logic. Somewhere it is failing and I couldn't figure it out.

 

Thanks,

Ravi Kumar,