Hello,
I am getting an error in trying to send an email from a Misc -> Execute Script step with the error of: "is failed: java.lang.NullPointerException: Cannot invoke method sendMail() on null object"
Unsure why its saying the MsicUtils is null, but below is the script to execute it:
groovy:
import com.pmease.quickbuild.util.Util
import com.pmease.quickbuild.entitymanager.*
File f = new File("\Path_To_Directory\Files");
File[] fileList = f.listFiles();
if(fileList != null){
for(File indexedFile : fileList){
int count = 0;
String var1 = "";
def usersAffected = [];
def FilesAffected = [];
def lines = indexedFile.readLines();
lines.each{ String line ->
if(count == 0){
Module = line;
}
else if(count == 1){
String[] Tokens = line.split(" ");
for(int a = 0; a < Tokens.length; a++){
usersAffected.add(Tokens[a]);
}
}
else if(count == 2){
String[] Tokens = line.split(" ");
for(int a = 0; a < Tokens.length; a++){
FilesAffected.add(Tokens[a]);
}
}
count++;
}
def attachments = []
def emailSetting = SettingManager.instance.getEmailSetting()
logger.info(usersAffected[0]);
logger.info(FilesAffected[0]);
logger.info("Before sending email.")
MiscUtils.sendMail(usersAffected.join(","), "Mainline Branch Sync Verifier", "Differences in files: " + FilesAffected.join(","), attachments, emailSetting)
}
}
Note: I append the ending of the email under usersAffected, just did not display it in the coode.
I am using QB 10.0
Thanks in Advance!
- solved #5
- replies 5
- views 2412
- stars 0