Gossamer Forum
Home : Products : DBMan : Customization :

How to Change text emails to HTML emails

Quote Reply
How to Change text emails to HTML emails
The emails that are automatically sent from the DBMan program send in text format... how can they be changed to HTML format?

Also, if the mass email mod is used - how can that also be changed from text format to HTML format?

TIA,

donm
Quote Reply
Re: [donm] How to Change text emails to HTML emails In reply to
Add the following to your mail sub

print MAIL "MIME-Version: 1.0\n";
print MAIL "Content-Type: text/html; charset=us-ascii\n";
print MAIL "Content-Transfer-Encoding: 7bit\n";

Stick this in below the To/From/Subject lines.

Then do <HTML><BODY> in the message part. You may have to post the mail routine you are using here - in order to make it work right, it may need some tweaking which is hard to do without seeing how you are going about sending your mail.
Quote Reply
Re: [Watts] How to Change text emails to HTML emails In reply to
Thanks for your help -

Here is the code that I am using:

sub html_mass_mail_form {
#----------------------------------------------------------
my ($message) = $_[0];

&html_page_top;

print qq|
<table border=0 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td class="tofronttext"><b>Mass Mailer</b><br>
|;

if ($message) { print qq|There was a problem: $message|; }
print qq|
Fill in the subject of your message, the message you wish to send and the criteria
for the users to whom you wish to send the email.</font>
|;

print qq|
<form action="$db_script_url" method="POST">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<table><tr><td align=right class="tofronttext">Subject:</td>
<td><input type=text name="subject" value="$in{'subject'}" size=40></td></tr>
<tr><td align=right class="tofronttext" valign="top">Your message:</td>
<td><textarea name="emailmessage" cols=40 rows=10 wrap="virtual">$in{'email_message'}</TEXTAREA></td></tr>
<tr><td align=center class="tofronttext" valign="top" colspan="2"><br><input type="checkbox" name="SendNewsletter" value="1">
<b>Newsletter</b> - Check here to mass mail the monthly newsletter<br><br></td></tr>
</table>|;

&html_record_form(%in);

print qq|
<center>
<input type="submit" name="mass_mail" value="Send Email" STYLE="background-color:#eeeeee;border:1 solid #999999; Cursor:HAND">
<input type="submit" value="Reset Form" STYLE="background-color:#eeeeee;border:1 solid #999999; Cursor:HAND">
</center>
</form>
|;
&html_footer;
&html_page_bottom;
}

Again, thank for your help!

Donm
Quote Reply
Re: [Watts] How to Change text emails to HTML emails In reply to
Ooops... I just noticed that I didn't post the mail sub - I posted the mail form. Duh!

Heres the mail sub that I am using... I tried it and then used the <HTML><BODY> tags in the message as suggested... but still get a text formatted message in the email instead of HTML formated.

Any ideas?

TIA,

Donm



Here's the code I am using:

sub send_email {
# --------------------------------------------------------
# This subroutine added for the private email mod
#

unless ($in{'EmailAddress'}) { $message = "You must fill in your email address<BR>"; }
unless ($in{'EmailAddress'} =~ /.+\@.+\..+/) { $message = "Your email address is not in the correct format.<BR>"; }
unless ($in{'subject'}) { $message .= "You must fill in a subject for your message.<BR>"; }
unless ($in{'emailmessage'}) { $message .= "Your email message is empty.<BR>"; }
%rec = &get_record($in{$db_key});
if (!%rec) { $message .= "The email address you requested could not be found.<BR>"; }
elsif (!$rec{$db_email_field}) { $message .= "There is no email address on file for this person.<BR>" }
if ($message) {
chomp($message); &html_send_email_form($message);
return;
}
open (MAIL, "$mailprog") || &cgierr("unable to open mail program");
print MAIL "To: $rec{$db_email_field}\n";
print MAIL "BCC: $BCC\n";
print MAIL "From: $in{'EmailAddress'}\n";
print MAIL "Subject: $in{'subject'}\n\n";
print MAIL "$in{'EmailAddress'} used the email system\n";
print MAIL "at http://xxxxxxx.xxx to send you this message\n";
print MAIL "-" x 75 . "\n\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 $in{'emailmessage'};
print MAIL "\n\n";
print MAIL &emailadv; ## Random E-Mail Advertisement
close (MAIL); &html_send_email_success;
}

Last edited by:

donm: Nov 5, 2003, 11:07 AM