Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,646,589
Community Members
 
Community Events
196
Community Groups

Add Bcc to custom email via post function

Deleted user Aug 17, 2017

Hello, 

I currently have a script that sends an email with no issues:

import com.atlassian.mail.Email;
import com.atlassian.mail.server.MailServerManager;
import com.atlassian.mail.server.SMTPMailServer;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.component.ComponentAccessor;

MailServerManager mailServerManager = ComponentAccessor.getMailServerManager()
SMTPMailServer mailServer = mailServerManager.getDefaultSMTPMailServer()
String currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().displayName

String issue = "JTP-123"

String subject = "Reminder Notification ${issue}"
String emailAddr = "emailadderss"

String body = """<h1>REMINDER</h1>

<p>Hi ${currentUser},<br/><br/>

This is a reminder that ${issue} was last updated 5 business days ago.</p>
"""

if (mailServer) {
Email email = new Email(emailAddr);
email.setSubject(subject);
email.setMimeType("text/html")
email.setBody(body);
mailServer.send(email);
} else {
// Problem getting the mail server from JIRA configuration, log this error
}

What im trying to do is add Bcc to the email that is sending via postfunction.

I can see that there is a method to add the Bcc called setBcc from this Doc

I've attempted to place the following line into my code - email.setBcc and provide an email address but it keeps throwing an error saying that setBcc does not exist.  

Does this work? or is there another way to get around this?

Many thanks, 

Pon

1 answer

1 accepted

2 votes
Answer accepted
Joshua Yamdogo _ Adaptavist
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Aug 17, 2017 • edited

I believe this is already possible. It's just not implemented into the UI and involves some simple code.

The paragraph underneath the Condition and Configuration block states the following:

You can pass additional variables to the body and subject template using the config map, and dynamically control recipients using the mail variable.

Basically, this means that you can add additional code that allows you to manipulate the recipients and the fashion in which they receive the mail. To add a recipient as a BCC, you can add a line of code similar to:

mail.setBcc("youremailhere@email.com")

It should go in the Condition and Configuration box: 

Screen Shot 2017-08-17 at 12.18.49 PM.png

Deleted user Aug 17, 2017

Thank you so much! It worked!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events