Email: different "from" address *display name* for a given notification

dmartinc
Tera Expert

Hello,

As explained in the documentation, it is possible to change the "From" address used by a particular Email Notification from the default one:
http://wiki.service-now.com/index.php?title=Scripting_for_Email_Notifications#Overriding_Email_Fields
This works well as long as one remembers to do email.setReplyTo() in addition to email.setFrom().

However, I am trying to change the "display name" of the "from" address. I would like a different value from the one in the 'glide.email.username' system property (e.g. 'Help Desk').

Since I see no method in the documentation or when introspecting the 'email' object, I thought I could write a "on before update" Business Rule that rewrites the headers of a sys_email record before it is sent.
And I think I succeeded, because the headers in the sys_email record do change. But when I look at the mail that arrives to my personal inbox, the headers still show the default value (e.g. "Help Desk" instead of "No reply - Help Desk" which I am trying to achieve).

Can anyone offer any help / advice?

Thanks for reading,
David

1 ACCEPTED SOLUTION

dmartinc
Tera Expert

Hello Harish, Saravanan,



To clarify, you have to do the following inside the "Message" field of your Email Notification or Email Template record:



<mail_script>


email.setFrom("Display Name <some.address @ company.com>");


email.setReplyTo("Display Name <some.address @ company.com>");


</mail_script>



(without the spaces around the @ character, which I added to avoid the email address to be mis-formatted by the comments system of this website)



Best regards,


David


View solution in original post

6 REPLIES 6

dmartinc
Tera Expert

Hello,

I found the solution: it works if you call email.setFrom and email.setReplyTo like this:
email.setFrom("Display Name ")

I thought it was worth a try and... it was 🙂

David


Harish Murikina
Tera Guru

Hi dmartinc,



                                Did you achieve your requirement. If yes please suggest me even i would like to do same way.



Regards,


Harish.


HI David



I tried   email.setFrom("Display Name ") , but the sender's email id is not fully overridden. I can see the sender's email id as below



DISPLAY_NAME[company@service-now.com]



I want to customize the email address as well. Any suggestion please?


dmartinc
Tera Expert

Hello Harish, Saravanan,



To clarify, you have to do the following inside the "Message" field of your Email Notification or Email Template record:



<mail_script>


email.setFrom("Display Name <some.address @ company.com>");


email.setReplyTo("Display Name <some.address @ company.com>");


</mail_script>



(without the spaces around the @ character, which I added to avoid the email address to be mis-formatted by the comments system of this website)



Best regards,


David