Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generating E-Mails from within Crystal

Status
Not open for further replies.

IdoMillet

Instructor
Feb 6, 2001
5,290
US
I want to draw your attention to a very cool UFL
(User Function Library) available from Chelsea Technologies at: as the "Outlook Library".

It allows you to automatically generate e-mails from within your report.

After downloading the demo or full ($99.97) zip file, you install the software following simple instructions in
a 2-page pdf file. It boils down, in my case, to:

1. copying a single 32KB dll (CRUFLMail.dll) to the C:\WINNT\Crystal\directory

2. Registering by issuing
“Regsvr32 C:\Winnt\Crystal\CRUFLMail.DLL”
from the Start, RUN command line.

3. Starting Crystal.

At this point you would notice 4 new functions in the Crystal formula editor under the “Additional Functions” category.

The simplest option is to use
OutLookMessageSendNow( Address, Subject, Body, CC, BCC)
To immediately send an Outlook e-mail message from within any report section where this formula is used. All arguments to this function can be dynamically specified using database columns and formula expressions.

To Build a more complex message or a message that collects its content from multiple sections, you begin with: OutlookMessageStart(Address, Subject, Body, CC, BCC).
This starts message, but doesn’t yet send it.

You then append Body content to the message by
Issuing calls to the OutLookMessageAppendBody(Body) function, which adds more text to the body of the message, but still doesn’t send it.

The message gets sent when you use the OutLookMessageSendBody(Body) to append one last piece of body text and send the resulting e-mail message.

I recently used this utility to send automatic e-mail messages to students who registered for courses for which they lack some prerequisites. The design process was simple and the speed of generating several hundred messages was impressive.

Within each course and section, each student formed a group with detail sections showing what prerequisites they are missing. In the group header for the student I started the e-mail with the following formula:

IF {?Enable Email} THEN
(
WhilePrintingRecords;
OutlookMessageStart ({@Clean E-mail}, // e-mail address
"Missing Prerequisites for " + {Missing_PreReq.course} + " ",
CHR(13) + "Dear " + {Missing_PreReq.name_pers_first} + " " + {Missing_PreReq.name_pers_last} + ":" + CHR(13) + CHR(13) +
"It looks like you have registered for " + {Missing_PreReq.course} + " Section " + {Missing_PreReq.section} + CHR(13) +
"even though you are missing the following prerequisites: " + CHR(13) +
"--------------------------------------------------"
+ CHR(13),"","") ;
)


The {?Enable Email} parameter is a technique I used to disable automatic e-mail using a simple TRUE/FALSE prompt. This is useful in order to allow the report to be designed and used without constantly spewing e-mails. I recommend you use a similar approach.

Note the use of CHR(13) to build line breaks into the text.

Finally, I recommend you start by setting the Address argument to your own e-mail address. This allows you to test the resulting e-mails without bothering other people.
When everything looks good, change the address argument to the true information provided by the database records.

I estimate most report designers would be able to generate e-mails from within their Crystal reports within 3 hours of downloading this very useful utility.

Cheers,
- Ido
ixm7@psu.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top