Gossamer Forum
Home : Products : DBMan : Customization :

Logic in Email

Quote Reply
Logic in Email
How do I use logic to control the display of the email of a record? Based on the contents of the record, I want to be able to have certain fields show up or not. I'm doing this with all the forms and display pages, but it's not working for emailing a record. Here's my code from add_success:

open (MAIL, "$mailprog") || &cgierr("Can't start mail program");
print MAIL "To: $admin_email\n";
print MAIL "From: $admin_email\n";
print MAIL "MIME-Version: 1.0\n";
print MAIL "Content-Type: text/html; charset=us-ascii\n";
print MAIL "Content-Transfer-Encoding: 7bit\n";
print MAIL "Subject: $rec{'CampAttending'} Online Camp Registration\n\n";


$email_message = qq|
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>

<p>$rec{'Address1'} |; if ($rec{'Address2'} ne "") {print qq|<br /> $rec{'Address2'}|;} print qq|</p>

</body>
</html>

|;

print MAIL $email_message;

close (MAIL);

The portion in red controls the second address line and line break so that it only shows up if Address2 is not blank. It send the email, but it cuts it off right at the |; and the rest of the message isn't sent.

Is there any way to make this happen?
Quote Reply
Re: [shalom777] Logic in Email In reply to
try changing
Code:
if ($rec{'Address2'} ne "") {print qq|<br /> $rec{'Address2'}|;} print qq|</p>

</body>
</html>

|;

to this:
Code:

if ($rec{'Address2'} ne "") {$email_message .= qq|<br /> $rec{'Address2'}|;}
$email_message .= qq|</p>

</body>
</html>

|;

also i don't see an opening html tag but that may not be relevant