Home > Articles > Business & Management

  • Print
  • + Share This

Sending Multiple-Line Messages

Most email messages are more than one line long. For example, suppose that instead of simply sending the message "Hello World," you wanted to send the message in Listing 7.

Listing 7 - Multiple-Line Message

Dear Barney,

How are you?

Fred

To send a multiple-line email message, you need to first place each line of text within a pair of double quotes (see Listing 8).

Listing 8 - Placing Text in Double Quotes

"Dear Barney,"

"How are you?"

"Fred"

Second, use the Visual Basic append operator (&) to attach a carriage return/line feed (vbcrlf) to the end of every text line except the last one (see Listing 9). Notice that because the second and fourth lines of the message don't have any text, no append symbol is needed before the vbcrlf.

Listing 9 - Adding Carriage Returns and Line Feeds

"Dear Barney," & vbcrlf &
         vbcrlf &
"How are you?" & vbcrlf &
         vbcrlf &
"Fred"

Finally, because Visual Basic expects all statements to fit on one line, if you have a multiple-line statement or value like the one above, you need to add the continuation operator (an underscore, _) to every line except the last one (see Listing 10).

Listing 10 - Adding the Continuation Operator

"Dear Barney," & vbcrlf & _
         vbcrlf & _
"How are you?" & vbcrlf & _
         vbcrlf & _
"Fred"

You're ready to send a multiple-line email message—simply set the value of the .body parameter in your mailing object to the string above (see Listing 11 for the completed version).

Listing 11 - ASP Mailing Script for a Multiple-Line Message

<%
set mail=server.CreateObject("CDONTS.NEWMAIL")
'
' Set delivery parameters
'
mail.from="fred@flintstone.com"
mail.to ="nick.flor@verizon.net"
'
' Set message parameters
'
mail.subject = "Hello"
mail.body  = "Dear Barney," & vbcrlf & _
                vbcrlf & _
        "How are you?" & vbcrlf & _
                vbcrlf & _
        "Fred"
'
' Send the mail
'
mail.send
'
' Delete the mailing object
'
set mail=nothing
%>
<HTML>
<HEAD>
<TITLE>Hello World Mailing Program</TITLE>
</HEAD>
<BODY>
Mail Sent!
</BODY>
</HTML>

Test this new version of your mailing script by saving the script, uploading it to your web server, and opening it in your browser. The recipient should see a message similar to Figure 5 in his or her mailing program.

Figure 5 A multiple-line email message.

We're done! At this point, you know how to send a message to a user (see the dark solid line in Figure 6). As you can see, however, there are many other information links (dashed lines) that you need to implement for a memetic, and each link has a number of important details that you need to get right if you want an effective memetic.

Figure 6 A multiple-line email message.

In the following article, I'll show you how to implement an entire memetic, by replacing the hard-coded recipient and message parameters with good, variable ones.

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.