Sending E-mail with Embedded HTML (e.g. In-line Graphics for Marketing Emails)

Mindwatering Incorporated

Author: Tripp W Black

Created: 04/21/2004 at 07:29 PM

 

Category:
Email F.A.Qs (Non-setup), General Web Tips
Sending Email
Other

Issue:
You want to send an email that contains images/HTML for marketing purposes. Attaching a PDF or Word document file is not an option.

Solution:
Option 1:
For Notes 6 and Outlook 2002 users, the simpliest way to send an inline message is to import/embed an image containing the marketting plug. This is very simple and requires no coding knowledge.

Option 2.
The average image size for Option 1 ranges between 50kb and 100kb. That can be too large for many users who keep their mail file close to their quota/size limit. A way to reduce that size is to send the page as HTML with the graphic images for the promotion residing on a web server. Below are the steps required to do this technique. Please realize that this is a "coding" solution requiring expertise of a web developer and/or mail system administrator.

*********************************************

Steps to create a html email
1. Open your html editor
(e.g. FrontPage, Dreamweaver, or Notepad)

2. Graphics, such as images, icons, or text artwork, must be stored on a web server to correctly appear in email software. Otherwise, the images will not display when the user views the emailed page. Instead of sending images in the email, you can choose to enhance the look solely using table and text color attributes.
2a. If using images, always have the source tag (src) use absolute URLS.
e.g. <img src="http://www.mydomain.com/marketing/images/someimage.gif">

3. If using Frontpage, Dreamweaver, or another graphical HTML editor, you may want to remove the HTML tags that the email client will not use. These include:
- Most meta-tags within the <HEAD>.
e.g. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
- The <Title> tag (the subject is generally used instead).
e.g. <TITLE>My Marketing Plug</TITLE>
- Comment Code
e.g. <!-- my comments -->
- ASP code and Javascript code - most email clients now would see that as "potentially harmful code".
e.g. <SCRIPT> ... </SCRIPT>
- Recode special characters. (ex: © to &copy; in HTML)

4. Name and save the page you have created (e.g. marketing.htm). If using Notepad, make sure to change the type of document so that you don't end up naming it with an extra extension (e.g. marketing.htm.txt)

5. Open your Email client software. Insert rather than attach the code.
(e.g. Outlook - Create mail -> Insert -> Text from file -> navigate and select your file from step #4 above.

6. Test send the message to various friends that have various email client software including Outlook, Netscape, Eudora, and Lotus Notes.

7. Once you have satisfied with this format, save it as template and then modify the contents for each mailing.

_______________________________________


Other Notes / Other Issues:

Some clients will display this HTML as just that -- HTML source code -- rather than displaying the resulting page. This can be due to several factors:

1. This is an older email client which cannot display HTML-based email. (not very common with newer versions of email clients)

2. The email still has what's called a "content-type" that is set to plain text rather than HTML. This can be tough to overcome. You may have to create a database program that creates and sends the page for you.
(e.g. Content-Type="multipart/relative" or Content-Type="text/html")


Below are examples of code from various web sources (Google, Notes.Net, etc.)


Perl Example on UNIX
*********************************************

#!/usr/local/bin/perl
$email = 'myemail@mydomain.com';
$youremail = 'recopient@herdomain.com';
open (MAIL,"|/var/qmail/bin/qmail-inject");
print MAIL "Subject: MY Marketing Mailn";
print MAIL "From: mynameoremail <$email>n";
print MAIL "To: hernameoremail <$youremail>n";
print MAIL "Content-type: text/htmlnn";
print MAIL "<html><body><p>n";
print MAIL "<blink>Hello World<br>I am HTML Text!</blink></p>n";
print MAIL "</body></html>n";
close (MAIL);
print "DONEn";

Notes:
for sendmail you may want to try the following adjustments:
#!/usr/local/bin/sendmail
...
open (MAIL,"|/usr/sbin/sendmail -t");
...
print MAIL "Content-type: text/htmlnn";

CDONTS EXAMPLE (Windows)
********************************************
Dim myMail
Set myMail = CreateObject("CDONTS.NewMail")

HTML = "<!DOCTYPE HTML PUBLIC ""-//IETF//DTD HTML//EN"">" & NL
HTML = HTML & "<html>"
HTML = HTML & "<head>"
HTML = HTML & "<meta http-equiv=""Content-Type"""
HTML = HTML & "HTML = HTML & ""content=""text/html; charset=iso-8859-1"">"""
HTML = HTML & "<title>Sample NewMail</title>"
HTML = HTML & "</head>"
HTML = HTML & "<body>"
HTML = HTML & "This is a sample message being sent using HTML. <BR></body>"
HTML = HTML & "</html>"

myMail.From = "Example@mydomain.com"
myMail.To = "Someone@theirdomain.com"
myMail.Subject = "Marketing Message"
myMail.BodyFormat = 0
myMail.MailFormat = 0
myMail.Body = HTML
myMail.Send
Set myMail = Nothing


Lotus Notes/LOTUSSCRIPT MIME EXAMPLE
(From Notes.net - Domino 6 forum, I think.)
*********************************************
Sub Initialize
Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim memo As NotesDocument
Dim body As NotesMIMEEntity
Dim header As NotesMIMEHeader
Dim child As NotesMIMEEntity
Dim stream As NotesStream
Dim recipient As String
Set db = s.CurrentDatabase
Set stream = s.CreateStream
s.convertmime = True
On Error Goto cleanup
Set dc = db.UnprocessedDocuments
Set doc = dc.getFirstDocument()
'SET STATUS FIELD TO "SENT"
While Not(doc Is Nothing)
Set memo = db.CreateDocument

'CREATE THE MEMO
Call memo.ReplaceItemValue("Form", "Memo")
Call memo.ReplaceItemValue("SendTo", doc.recipient(0))
Set body = memo.CreateMIMEEntity

'ADD SUBJECT HEADER
Set header = body.CreateHeader("Content-Type")
Call header.SetHeaderVal("multipart/relative")
Set header = body.CreateHeader("Subject")
Call header.SetHeaderVal("Pledge Reminder")

'ADD GREETING
Set child = body.CreateChildEntity
Call stream.WriteText("<font face=Verdana color=#000099 size=2>Dear " + doc.FirstName(0) + ":</font><br><br>")
Call stream.WriteText("<font face=Verdana color=#000099 size=2>Thank you for your recent commitment. Our records indicate that we have not yet received your pledge payment for:</font><br><br>")
Call stream.WriteText("<font face=Verdana color=#000099 size=2>Pledge Date: " + doc.PledgeDate(0) + "</font><br>")
Call stream.WriteText("<font face=Verdana color=#000099 size=2>Amount: $" + doc.PledgeAmount(0) + "</font><br><br>")
Call stream.WriteText("<font face=Verdana color=#000099 size=2>Thank you!</font>")
Call child.SetContentFromText(stream, "text/html", ENC_NONE)
Call stream.Truncate
doc.Status = "Sent"
Forall x In doc.recipient
Call memo.Send(False, x)
End Forall
Call doc.Save( False, True )
Set doc = dc.getNextDocument( doc )
Wend

cleanup:
s.ConvertMime = False
End Sub

previous page