- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 05:51 AM
Hi ,I have requirement to to send an email through code .
But not through the eventqueue or notifications only from code .
so I have created a record in sysemail table it is created a record but not sending mail to users .
here is the code I tried
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 06:00 AM - edited 08-29-2024 06:02 AM
Hi @kummara _siva,
Try this:
var email = new GlideEmailOutbound();
email.setSubject("subjectss");
email.setBody("body");
email.addAddress("to","kumarasivakumar.kanini@gmail.com");
email.send();
If you found my response helpful, please mark it as Solution and Helpful.
Thanks and Regards,
Ehab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 06:03 AM - edited 08-29-2024 06:09 AM
Hi @kummara _siva,
Is there any particular reason why you don't want to (or can't) trigger the email via events or notifications?
What about via Flow Designer / Workflow?
The only other way I could think of would be via the GlideEmailOutbound API.
Check the below link and article from @Vedhavrath_Kond who has explained this including emails very well - kudos.
(For future use and in case links break, here's the sample code, but I urge you to view the article.)
Example:
var mail = new GlideEmailOutbound();
mail.setReplyTo('agent@abc.com');
mail.setSubject('Testing outbound email');
mail.addAddress('cc', 'admin@example.com');
mail.setBody('Hello world!');
mail.save();
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
SN Docs link: https://developer.servicenow.com/dev.do#!/reference/api/washingtondc/server/no-namespace/c_GlideEmai...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 06:00 AM - edited 08-29-2024 06:02 AM
Hi @kummara _siva,
Try this:
var email = new GlideEmailOutbound();
email.setSubject("subjectss");
email.setBody("body");
email.addAddress("to","kumarasivakumar.kanini@gmail.com");
email.send();
If you found my response helpful, please mark it as Solution and Helpful.
Thanks and Regards,
Ehab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 06:03 AM - edited 08-29-2024 06:09 AM
Hi @kummara _siva,
Is there any particular reason why you don't want to (or can't) trigger the email via events or notifications?
What about via Flow Designer / Workflow?
The only other way I could think of would be via the GlideEmailOutbound API.
Check the below link and article from @Vedhavrath_Kond who has explained this including emails very well - kudos.
(For future use and in case links break, here's the sample code, but I urge you to view the article.)
Example:
var mail = new GlideEmailOutbound();
mail.setReplyTo('agent@abc.com');
mail.setSubject('Testing outbound email');
mail.addAddress('cc', 'admin@example.com');
mail.setBody('Hello world!');
mail.save();
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
SN Docs link: https://developer.servicenow.com/dev.do#!/reference/api/washingtondc/server/no-namespace/c_GlideEmai...