How to add CC or BCC in email notification?

User150433
Tera Guru

How to add CC or BCC while using email notifications and templates?
There is no option to set CC or BCC field in that.

12 REPLIES 12

HI Fatah,



Were is this code to be placed, in the email notification which will we are tying to send out in the email body?



Thanks,


The code can be placed in either the email body and/or an email template for an email notification.


But, note that one needs to wrap the code within a <mail_script>.. </mail_script> block.


Here is my version which I inserted within an email template that was successful and CC's the user (sys_id) provided within parm1 of an event.


Note the template print of the date is not required, but helps demonstrate that one can use an existing block...



                                                                                                                      <mail_script>
                                                                                                                      var dateTime = new Packages.java.text.SimpleDateFormat( "MMMM dd, yyyy" );
                                                                                                                      template.print( dateTime.format( new Packages.java.util.Date()) +"\n" );


                                                        // Add CC if manager (or any other user) provided within event parm1
                                                        if (!event.parm1.nil()) {
                                                            //get param's and add to cc
                                                            //get user records
                                                            var user = new GlideRecord("sys_user");
                                                            user.addQuery("sys_id", event.parm1);
                                                            user.addQuery("notification", 2); //email
                                                            user.addQuery("email", "!=", "");
                                                            user.query();
                                                            if (user.next()) {
                                                                    //add to cc list
                                                                    email.addAddress("cc", user.email, user.getDisplayValue());
                                                            }
                                                        }
                                                                                                                      </mail_script>

bostonsnow
Kilo Guru

Hello,



Does anyone know if SNOW plans to make this functionality (specifying cc and bcc recipients) available in the UI?



Thanks,



Mike