• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 25. Visio Automation and Microso... > Getting Data from Outlook

Getting Data from Outlook

Listing 25.3 illustrates how, subsequent to obtaining a reference to the MAPI folder object, you can read information about each message in the subject inbox. This information includes the sender's name, the subject, the message size in bytes, the time the message was received, and the entire message contents. With this information, you can then construct a process diagram based on Visio's organizational charting to display all the information about the messages in the inbox. The code is in FromOutlook2000 CH25.vsd on the companion CD.

Listing 25.3. Building an Organizational Chart from Outlook Data

Public Sub FromOutlook2000()
    Dim pagObjVis As Visio.Page
   Dim shpObjVisThisShape1 As Visio.Shape
   Dim shpObjVisThisShape2 As Visio.Shape
   Dim stnObjVis As Visio.Document
   Dim mastObjVis As Visio.Master
   Dim otlkObkApp As Outlook.Application
   Dim otlkObjNmeSpc As Outlook.NameSpace
   Dim otlkObjFolder As Outlook.MAPIFolder
   Dim intCounter As Integer
   Dim intFirstTrigger As Integer
   Dim dblHeightSpacing As Double
   Dim dblDropX As Double
   Dim dblDropY As Double
   Dim szShapeText As String
   Dim celObjVis As Visio.Cell
   intFirstTrigger = 1
   Set pagObjVis = Visio.ActivePage
   Set stnObjVis = Visio.Documents.Item("Organization Chart Shapes.VSS")
   Set otlkObjApp = CreateObject("Outlook.Application")
   Set otlkObjNmeSpc = otlkObjApp.GetNamespace("MAPI")
   otlkObjNmeSpc.Logon
   Set otlkObjFolder = otlkObjNmeSpc.GetDefaultFolder(olFolderInbox)
   dblHeightSpacing = 0
   For intCounter = 1 To otlkObjFolder.Items.Count
    szShapeText = ""
    With otlkObjFolder.Items(intCount)
        dblDropX = pagObjVis.PageSheet.Cells("PageWidth").Result(visNumber) / 2
         dblDropY = pagObjVis.PageSheet.Cells("PageHeight").Result(visNumber)
        Set mastObjVis = stnObjVis.Masters.Item("Executive")
         Set shpObjVisThisShape1 = pagObjVis.Drop(mastObjVis, dblDropX, dblDropY - (dblHeightSpacing + 0.25))
         dblHeightSpacing = shpObjVisThisShape1.Cells("Height").Result(visNumber)
         shpObjVisThisShape1.Text = "Message Number: " & Str(intCounter)
         Set mastObjVis = stnObjVis.Masters.Item("Staff")
         dblDropY = shpObjVisThisShape1.Cells("PinY").Result(visNumber)
         Set shpObjVisThisShape2 = pagObjVis.Drop(mastObjVis, dblDropX - 1, dblDropY - dblHeightSpacing)
         szShapeText = "Sender Name: " & .SenderName
        shpObjVisThisShape2.Text = szShapeText
         Set celObjVis = shpObjVisThisShape2.Cells("Controls.X1")
         celObjVis.GlueToPos shpObjVisThisShape1, 0.5, 0#
         Set shpObjVisThisShape2 = pagObjVis.Drop(mastObjVis, dblDropX - 1, dblDropY - (dblHeightSpacing + 0.25))
         szShapeText = "Subject: " & .Subject
        shpObjVisThisShape2.Text = szShapeText
         Set celObjVis = shpObjVisThisShape2.Cells("Controls.X1")
         celObjVis.GlueToPos shpObjVisThisShape1, 0.5, 0#
         Set shpObjVisThisShape2 = pagObjVis.Drop(mastObjVis, dblDropX - 1, dblDropY - (dblHeightSpacing + 0.5))
         szShapeText = "Size: " & .Size
        shpObjVisThisShape2.Text = szShapeText
         Set celObjVis = shpObjVisThisShape2.Cells("Controls.X1")
         celObjVis.GlueToPos shpObjVisThisShape1, 0.5, 0#
         Set shpObjVisThisShape2 = pagObjVis.Drop(mastObjVis, dblDropX - 1, dblDropY - (dblHeightSpacing + 0.75))
         szShapeText = "Received Time: " & .ReceivedTime
        shpObjVisThisShape2.Text = szShapeText
         Set celObjVis = shpObjVisThisShape2.Cells("Controls.X1")
         celObjVis.GlueToPos shpObjVisThisShape1, 0.5, 0#
         Set mastObjVis = stnObjVis.Masters.Item("Position")
         Set shpObjVisThisShape2 = pagObjVis.Drop(mastObjVis, dblDropX + 1, dblDropY - (dblHeightSpacing + 0.75))
         szShapeText = "Message Text: " & vbCrLf & .Body
        shpObjVisThisShape2.Text = szShapeText
         Set celObjVis = shpObjVisThisShape2.Cells("Controls.X1")
         celObjVis.GlueToPos shpObjVisThisShape1, 0.5, 0#
         dblHeightSpacing = dblHeightSpacing + shpObjVisThisShape2.Cells("Height").Result(visNumber)
   Next intCounter
End Sub


					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint