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 Basic.NET>Outlook Messages to TIFF

Converting Microsoft Outlook Messages to TIFF


'----------------------------------------------------------------------
' 1) Microsoft Outlook 2000 or above should be installed and activated on your PC.
'
' 2) Universal Document Converter 5.2 or above should be installed, too.
'
' 3) Open your project in Microsoft Visual Basic.NET.
'
' 4) In Visual Basic main menu press "Project->Add Reference...".
'
' 5) In "Add Reference" window go to "COM" tab and double click into 
'    "Universal Document Converter Type Library".
'----------------------------------------------------------------------

Private Shared readyFlag As Boolean = False
Private Shared myTimer As New System.Windows.Forms.Timer()

Private Shared Sub TimerEventProcessor(ByVal myObject As Object, ByVal myEventArgs As EventArgs)
' This is the method to run when the timer is raised.

    myTimer.Stop()
    readyFlag = True

End Sub


Private Sub WaitSomeTime(ByVal nSec As Single)

    AddHandler myTimer.Tick, AddressOf TimerEventProcessor
    myTimer.Interval = nSec * 1000
    myTimer.Start()

    While readyFlag = False
      ' Processes all the events in the queue.
        Application.DoEvents()
    End While

End Sub


Private Sub PrintOutlookMsgToTIFF(ByVal strFilePath As String)

    Const olDiscard = 1 ' = Outlook.OlInspectorClose.olDiscard

    Dim objUDC As UDC.IUDC
    Dim itfPrinter As UDC.IUDCPrinter
    Dim itfProfile As UDC.IProfile

    Dim objOutlook As Object
    Dim itfMsg As Object

    objUDC = New UDC.APIWrapper
    itfPrinter = objUDC.Printers("Universal Document Converter")
    itfProfile = itfPrinter.Profile

    ' 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
    itfProfile.FileFormat.ActualFormat = UDC.FormatID.FMT_TIFF
    itfProfile.FileFormat.TIFF.ColorSpace = UDC.ColorSpaceID.CS_BLACKWHITE
    itfProfile.FileFormat.TIFF.Compression = UDC.CompressionID.CMP_CCITTGR4

    itfProfile.OutputLocation.Mode = UDC.LocationModeID.LM_PREDEFINED
    itfProfile.OutputLocation.FolderPath = "C:\Out"

    itfProfile.PostProcessing.Mode = UDC.PostProcessingModeID.PP_OPEN_FOLDER

    ' Open MS Outlook as COM-server
    objOutlook = CreateObject("Outlook.Application")

    ' Open Outlook MSG file
    itfMsg = objOutlook.CreateItemFromTemplate(strFilePath)

    ' And print it on the default printer
    Call itfMsg.PrintOut()

    ' Close opened file
    itfMsg.Close(olDiscard)

    ' Wait until Outlook finished printing process
    WaitSomeTime(5)

    ' Close Outlook application
    Call objOutlook.Quit()
    objOutlook = Nothing

End Sub


© fCoder SIA Chi è fCoder SIA | Mappa del sito