Redirecting to Send an Email

The LEADTOOLS ePrint 5 C DLL provides a mechanism for redirecting a print command to send an email message. This requires creating an email redirection device context (DC), which is obtained by calling the L_EpnCreateEmailDC function.

The created DC can be used as an ordinary printer DC. Each GDI command executed for this DC will be saved as a file using the file save options pointed to by the pSaveOptions parameter. These files will be attached to an email message and sent to the mail recipient(s) using the options pointed to by pMailMessageInfo parameter.

Before using the created DC, the user should call the StartDoc and StartPage Windows C DLL functions. After using the created DC the user should call the EndPage and EndDoc Windows C DLL functions.

The L_EpnCreateEmailDC function takes a pointer to an EPNMAILMESSAGEINFO structure, which contains information about the email recipients, copy recipients; email message. It also takes a pointer to an EPNPRINTERSAVEOPTIONS structure, which contains information on saving the "printed" material. When the user sends a print command, the active material in the program from which the print command is sent is saved and attached to an email message that is then sent. The material is saved according to the information provided in the EPNMAILMESSAGEINFO structure used to create the email device context.

If the mail configuration settings for a specific printer were not set, then the user should set these using the L_EpnSetPrinterEmailConfiguration function before calling the L_EpnCreateEmailDC function.

As an example, assume a user has created an email device context that will send an email. In the pSaveOptions parameter of the L_EpnCreateEmailDC the user has indicated that the material will be saved in a single multi-page TIFF file, C:\image.tif. Next, assume the user is working on a three pages document in some word processing software and has set the printer to use LEADTOOLS ePrint. When the user "prints" the active three pages document, the three pages document is saved to the multi-page file C:\image.tif, attached to the email and the email sent to the designated address.

When the created DC is no longer needed, it should be deleted by calling L_EpnDeleteDC. For every DC created using L_EpnCreateEmailDC there must be a call to L_EpnDeleteDC to free it.

For OEM Printers:

If the OEM printer is locked, then the user can use it indirectly by using this function.

To use the locked OEM printer indirectly, pass a valid data to the pExtraOptions parameter. The pExtraOptions parameter is a pointer to an EPNEXTRADCOPTIONS structure. Please note that the pszPassword member of the EPNEXTRADCOPTIONS structure must be filled by the administration password that was used when the OEM printer was installed by calling the L_EpnInstallOEMPrinter function.

If the printer is locked and either NULL or an invalid password is supplied in pExtraOptions, the L_EpnCreateEmailDC function will fail and return NULL.

For more information, refer to Locking and Unlocking the OEM ePrint Printer.