Universal Document Converter
Informazioni sul prodotto
Scarica
Acquista
Tutorial
Soluzioni per sviluppatori
Servizio di assistenza
Chi è fCoder SIA


      Cerca nel sito
   


      Conversioni più richieste
Da Adobe PDF a JPEG
Da documento Word a PDF
Da foglio di lavoro Excel a PDF
Da PowerPoint a JPEG
Da disegno Visio a PDF
Da disegno AutoCAD a TIFF
Da pagina Web a JPEG
Convertire di lavoro Excel in PDF
Convertire da DjVu in PDF
Pagine Web in PDF



Pagina principale>Developer Solutions>Examples>Visual C++>Outlook Messages to TIFF

Converting Microsoft Outlook Messages to TIFF


//////////////////////////////////////////////////////////////////
// This example was designed for using in Microsoft Visual C++ from 
// Microsoft Visual Studio 2003 or above.
//
// 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. You must initialize the COM before you call any COM method.
// Please insert "::CoInitialize(0);" in your application initialization
// and "::CoUninitialize();" before closing it.
//
// 4. Import Office libraries for 32-bit version of Windows.
// For 64-bit version please change "C:\\Program Files\\" to
// "C:\\Program Files (x86)\\" in all pathes.

#pragma message("Import MSO.DLL")
// MS Office 2000 -> "C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE10\\MSO.DLL"
// MS Office 2003 -> "C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE11\\MSO.DLL"
// MS Office 2007 -> "C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE12\\MSO.DLL"
#import "C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE10\\MSO.DLL" \
	rename_namespace("MSO"), auto_rename

#pragma message("Import VBE6EXT.OLB")
#import "C:\\Program Files\\Common Files\\Microsoft Shared\\VBA\\VBA6\\VBE6EXT.OLB" \
    rename_namespace("VBE6EXT")

#pragma message("Import MS Outlook API")
// MS Office 2000 -> "C:\\Program Files\\Microsoft Office\\OFFICE\\MSOUTL9.OLB"
// MS Office 2003 -> "C:\\Program Files\\Microsoft Office\\OFFICE11\\MSOUTL.OLB"
// MS Office 2007 -> "C:\\Program Files\\Microsoft Office\\OFFICE12\\MSOUTL.OLB"
#import "C:\\Program Files\\Microsoft Office\\OFFICE\\MSOUTL9.OLB"\
    rename_namespace("OUTLOOK"), auto_rename

// 5. Import Universal Document Converter software API:
#import "progid:udc.apiwrapper" rename_namespace("UDC")
//////////////////////////////////////////////////////////////////
#include 

void WaitSomeTime( int nSec )
{
  CTime tmBegin = CTime::GetCurrentTime();

  do
  {

    MSG msg;
    while( PeekMessage( &msg, 0, 0, 0, PM_REMOVE ) ) 
    {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
    }

  }
  while( ( CTime::GetCurrentTime() - tmBegin ).GetTotalSeconds() < nSec );
}

void PrintOutlookToTIFF( CString sFilePath )
{
  UDC::IUDCPtr pUDC(__uuidof(UDC::APIWrapper));
  UDC::IUDCPrinterPtr itfPrinter = pUDC->Printers["Universal Document Converter"];
  UDC::IProfilePtr itfProfile = itfPrinter->Profile;

// Set Universal Document Converter as default printer, because
// Outlook's API interface allow printing only on default printer
   pUDC->DefaultPrinter = "Universal Document Converter";

// Use Universal Document Converter API to change settings of converterd document
  itfProfile->FileFormat->ActualFormat = UDC::FMT_TIFF;
  itfProfile->FileFormat->TIFF->ColorSpace = UDC::CS_BLACKWHITE;
  itfProfile->FileFormat->TIFF->Compression = UDC::CMP_CCITTGR4;
 
  itfProfile->OutputLocation->Mode = UDC::LM_PREDEFINED;
  itfProfile->OutputLocation->FolderPath = L"C:\\Out";

  itfProfile->PostProcessing->Mode = UDC::PP_OPEN_FOLDER;

// Run Microsoft Outlook as COM-server
  OUTLOOK::_ApplicationPtr objOutlook( L"Outlook.Application" );
  OUTLOOK::_MailItemPtr itfMsg;

// Open document from file
  itfMsg = objOutlook->CreateItemFromTemplate( (LPCTSTR)sFilePath );

// And print it on the default printer
  itfMsg->PrintOut();

// Close opened file
  itfMsg->Close( OUTLOOK::olDiscard );

// Wait until Outlook finished printing process
  WaitSomeTime( 5 );

// Close Outlook application
  objOutlook->Quit();
}


© fCoder SIA Chi è fCoder SIA | Mappa del sito