Send Email to user only if their ID is not null

I have the following code behind a button for deleting an object. The first email is sending, but the second email in the if statement is not. I dont want the email to be sent if the memberID is null. I am getting the memberID from a label in another view and I am passing it in as a parameter. I have tried putting the parameter in str() and without str() as well as using != or <> , as well as “” or “null”.

system.net.sendEmail(smtpProfile="SendInBlue", fromAddr="notification@ticketingsystemfyp.com", subject="Request Details Updated.", body="Hello, " + str(self.view.params.userFname) + ", your Request with the Request ID " + str(self.view.params.requestID) + " has been deleted. Your request was deleted on " + str(system.date.now()) + ". Request Nature: " + str(self.view.params.nature) + ". Request Description: " + str(self.view.params.requestDes) + ". Your request was deleted by " + str(self.session.props.auth.user.firstName) + ", their ID is " + str(self.session.props.auth.user.id) + ".", html=1, to= str(self.view.params.userEmail))
if self.view.params.memberID != "null":
	system.net.sendEmail(smtpProfile="SendInBlue", fromAddr="notification@ticketingsystemfyp.com", subject="Request Details Updated.", body="Hello, " + str(self.view.params.memberFname) + ", your Request with the Request ID " + str(self.view.params.requestID) + " has been deleted. Your request was updated on " + str(system.date.now()) + ". Request Nature: " + str(self.view.params.nature) + ". Request Description: " + str(self.view.params.requestDes) + ". Your request was deleted by " + str(self.session.props.auth.user.firstName) + ", their ID is " + str(self.session.props.auth.user.id) + ".", html=1, to= str(self.view.params.memberEmail))`

try:

if self.view.params.memberID != None:
1 Like

Thanks, Kevin, that has done the trick.