Universal Document Converter
fCoder SIAについて


      Video tutorial
Show tutorial

Main page>Developer Solutions>Examples>Delphi>Outlook Messages to TIFF

Converting Microsoft Outlook Messages to TIFF

//////////////////////////////////////////////////////////////////////////////////////////////////// // This example was designed for using in Delphi 7 or higher. // // 1. Microsoft Outlook 2000 or above should be installed and activated on your PC. // Microsoft Outlook Express does not have COM interface and cannot be used as COM-server! // // 2. Universal Document Converter 5.2 or above should be installed, too. // // 3. Add "Universal Document Converter Type Library" and "Microsoft Outlook XX.0 Object Library" type libraries to the project. // XX is the Microsoft Office version installed on your computer. // // Delphi 7: // Use the Project | Import Type Library menu. // Delphi 2006 or latter: // Use the Component | Import Component menu. // // Clear the "Generate Component Wrapper" checkbox and click the "Create Unit" button (Delphi 7) or // select the "Create Unit" option (Delphi 2006 or latter). // // 4. Notice that the number of Microsoft Outlook's method parameters may depend on the Office version. // //////////////////////////////////////////////////////////////////////////////////////////////////// program OutlookToTIFF; {$APPTYPE CONSOLE} uses SysUtils, Variants, Dialogs, ActiveX, Windows, UDC_TLB, Outlook_TLB; procedure PrintOutlookToTIFF(OutlookFilePath: string); var objUDC: IUDC; Printer: IUDCPrinter; Profile: IProfile; OutlookApp: OutlookApplication; MailItem: Outlook_TLB.MailItem; ReadOnly: OleVariant; Missing: OleVariant; begin //Create a UDC object and get its interfaces objUDC := CoAPIWrapper.Create; Printer := objUDC.get_Printers('Universal Document Converter'); Profile := Printer.Profile; //Use Universal Document Converter API to change settings of convertered document Profile.PageSetup.ResolutionX := 300; Profile.PageSetup.ResolutionY := 300; //Set Universal Document Converter as default printer, because //Outlook's API interface allow printing only on default printer objUDC.DefaultPrinter := 'Universal Document Converter'; //Use Universal Document Converter API to change settings of converterd document Profile.FileFormat.ActualFormat := FMT_TIFF; Profile.FileFormat.TIFF.ColorSpace := CS_BLACKWHITE; Profile.FileFormat.TIFF.Compression := CMP_CCITTGR4; Profile.OutputLocation.Mode := LM_PREDEFINED; Profile.OutputLocation.FolderPath := 'C:\UDC Output Files'; Profile.PostProcessing.Mode := PP_OPEN_FOLDER; //Run Microsoft Outlook as COM-server OutlookApp := CoOutlookApplication.Create; ReadOnly := True; Missing := Variants.EmptyParam; //This will be passed when ever we don稚 want to pass value //Open document from file MailItem := OutlookApp.CreateItemFromTemplate(OutlookFilePath, Missing) as Outlook_TLB.MailItem; //And print it on the default printer MailItem.PrintOut(); //Close opened file MailItem.Close(olDiscard); //Wait until Outlook finished printing process Sleep(5000); //Close Outlook application OutlookApp.Quit(); end; var TestFilePath: string; begin TestFilePath := ExtractFilePath(ParamStr(0)) + 'TestFile.msg'; CoInitialize(nil); try PrintOutlookToTIFF(TestFilePath); finally CoUninitialize; end; end.

© fCoder SIA fCoder SIAについて | サイトマップ