Universal Document Converter
Product Overview
Download
Purchase
Tutorials
Developer Solutions
Support Service
About fCoder SIA


      Site search
   


      Popular conversions
PDF to JPG converter
Convert Word to PDF
Convert PDF to TIFF
Autocad to PDF converter
Convert Word to JPG
Powerpoint to PDF converter
Printing to PDF
Convert Excel to PDF
Convert DJVU to PDF
Convert Web Page to PDF

      Video tutorials
Show tutorial



Main page>Developer Solutions>Examples>Visual Basic.NET>Outlook Messages to TIFF

Converting Microsoft Outlook Messages to TIFF for Visual Basic.NET


'----------------------------------------------------------------------
' 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 About fCoder SIA | Privacy Policy | Site Map