Simple notification + mail script not working as expected ?

diogo_ramos
Mega Expert

Hello everyone,

Currently I'm facing a problem where I define a notification like this:

find_real_file.png

Then I use a mailscript to dynamically change the from address and the reply to address:

find_real_file.png

I get this when I trigger the notification:
find_real_file.png

So I can see that mail script works because the subject is replaced, but the from address / reply to, is not modified when in the notification there is a value in those fields, ready the wiki: https://docs.servicenow.com/bundle/kingston-servicenow-platform/page/script/server-scripting/reference/r_MailScriptAPI.html

In the Mail api it says

  • setFrom(String address): override the sender address.

So I was expecting this to work, I know that if in the notification we don't have anything set in the from/reply to this mail script works fine, would like to know your thoughts.

Cheers,
Diogo

1 ACCEPTED SOLUTION

Dubz
Mega Sage

I found that if you have hard set the from and to address on the notification it will use those details regardless of any mail scripts you have running. If you remove those values the notification will automatically use the instance address or whatever one you have set up as your from address in your SMTP email account, then you can molest it with mail scripts.

View solution in original post

3 REPLIES 3

Dubz
Mega Sage

I found that if you have hard set the from and to address on the notification it will use those details regardless of any mail scripts you have running. If you remove those values the notification will automatically use the instance address or whatever one you have set up as your from address in your SMTP email account, then you can molest it with mail scripts.

Yeah I found that also, just think that maybe the Wiki could be more explicit when they say "override".

Cheers for the answer.
Diogo

Yeah agreed, a little note about that in the docs would be useful. If you're question is now answered please mark my answer correct to close the thread down.

 

Cheers

Dave