Formatting and wrapping plain-text e-mail
This section explains how you can use functions supplied with Outbound E-mail to format the plain-text version of your e-mail message. The functions provided are:
ConvertXHTMLToText()—which enables you to turn a Format Area or other XHTML-formatted content into a plain-text equivalentWrapText()—which enables you to wrap plain text to a fixed line lengthSetLineWidth()—which you use to set this fixed line length
Formatting plain text
The following example shows how you convert a Format Area or other XHTML field (called "myXHTMLField" in this example) to plain text:
Dim lStrXHTML
Dim lStrConverted
Dim lStrConvertedNoTracking
lStrXHTML =
ComponentPresentation.Component.Fields.Item("myXHTMLField").Value(1)
lStrConverted = OutboundEmail.ConvertXHTMLToText(lStrXHTML)
WriteOut lStrConverted & vbCrLf
This code converts the XHTML found in the Component Field called myXHTMLField to plain text and puts the result in lStrConverted. Turning an XHTML Field into plain text affects both the tracking and the resolving of hyperlinks.
Tracking hyperlinks converted to plain text
- You can display the URL of the tracking page (default behavior). This allows you to track the link, but the appearance of the link may keep some visitors from accessing it.
- You can display the actual target of the hyperlink. This looks more inviting and recognizable to the visitors, but the link is no longer tracked. To do this, add a second parameter to
ConvertXHTMLToText()and set it toFalse. For more information, see ConvertXHTMLToText().
Resolving hyperlinks converted to plain text
If the actual target of your hyperlink is a Content Manager Component (a URI), rather than a Web page (a URL), you must ensure that the link is resolved. If the hyperlink to a URI is tracked, whether in XHTML or in plain text, Outbound E-mail resolves the link automatically for you.
However, if you choose to display the actual target of the hyperlink by adding a False parameter to your ConvertXHTMLToText() call, Outbound E-mail does not resolve the link. You must resolve the link yourself using Dynamic Link Resolving functionality offered by Content Delivery. To use Dynamic Link Resolving to resolve a plain-text link to a URI, do the following:
- Create and publish an ASP or JSP page that accepts a parameter (for example, URI) and calls the standard SDL Tridion Linking API with that parameter to resolve the link.
- Instead of writing out the actual URI in your e-mail message, write the URL of the ASP or JSP page you created and pass the URI as a parameter:
WriteOut "http://www.mycomp.com/campaign/resolver.asp?URI=" & oLink.ID
For more information on using the Linking API, see Types of links.
Wrapping plain text
If you do not wrap the plain-text version of your e-mail message, each paragraph becomes one long line and people reading the e-mail may have to scroll from left to right a lot. To prevent long lines in your plain-text e-mail message, first set the line length by calling the OutboundEmail.SetLineWidth() method. Below that call, use the following command:
strWrappedText = OutboundEmail.WrapText(strTextToWrap)
where strTextToWrap contains the plain-text version of your e-mail. Calling OutboundEmail.WrapText() wraps your e-mail text to the line length specified.
You can also add the line length as a second parameter to OutboundEmail.WrapText(), in which case it overrides any length set by OutboundEmail.SetLineWidth(). In that case, only the text supplied in this call is wrapped to this length. Any subsequent calls to OutboundEmail.WrapText() use the length set by OutboundEmail.SetLineWidth() again (or their own value).
If you do not use OutboundEmail.SetLineWidth() and also do not use the second parameter for OutboundEmail.WrapText(), line length is set to 72.