Redirecting to Send an Email

The LEADTOOLS ePrint 5 COM 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 CreateEmailDC method.

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 methods. After using the created DC the user should call the EndPage and EndDoc methods.

The CreateEmailDC method takes a pointer to an IEpnMailMessageInfo Object, which contains information about the email recipients, copy recipients; email message. It also takes a pointer to an IEpnPrinterSaveOptions object, 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 IEpnMailMessageInfo object 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 SetPrinterEmailConfiguration method before calling the CreateEmailDC method.

As an example, assume a user has created an email device context that will send an email. In the pPrinterSaveOptions parameter of the CreateEmailDC, 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 three page-long document using word processing software, and has set the printer to use LEADTOOLS ePrint. When the user "prints" the active three-page document, the document will be 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 DeleteDC. For every DC created using CreateEmailDC there must be a call to DeleteDC to free it.

For OEM Printers:

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

To use the locked OEM printer indirectly, pass a valid data to the pExtraOptions parameter. The pExtraOptions parameter is a pointer to an IEpnExtraDcOptions object. Please note that the Password property of the IEpnExtraDcOptions object must be filled by the administration password that was used when the OEM printer was installed by calling the InstallOEMPrinter method.

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

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