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

Sending Data to Outlook

Listing 25.2 illustrates how a Visio organizational chart diagram containing Visio SmartShape symbols with a Prop.eMail Custom Property cell can be iterated through and an email message that is sent to each of the persons, who are represented by the SmartShape symbols. After you obtain a reference to the folder object in Outlook, you use the CreateItem method of the Outlook application object and then use the .Recipients property to pass the Custom property from Visio to the message object. Additionally, you use the .Subject and the.Body properties to add the required information prior to using the .Send method to send off the message to the designated recipient. This code is in ToOutlook2000 CH25.vsd on the companion CD.

Listing 25.2. Mailing to a Visio Recipient Listing Using Outlook

Global g_MailItem As Object
Public Sub MailIntoHistory()
    Dim pagObjVis As Visio.Page
    Dim shpObjVis As Visio.Shape
    Dim celObjVis As Visio.Cell
    Dim intCounter As Integer
    Dim otlkObjApp As Outlook.Application
    Dim otlkObjNmeSpc As Outlook.NameSpace
    Dim otlkObjFolder As MAPIFolder
    Set otlkObjApp = CreateObject("Outlook.Application")
    Set otlkObjNmeSpc = otlkObjApp.GetNamespace("MAPI")
    otlkObjNmeSpc.Logon
    Set otlkObjFolder = otlkObjNmeSpc.GetDefaultFolder(olFolderInbox)
    Set pagObjVis = Visio.ActivePage
    For intCounter = 1 To pagObjVis.Shapes.Count
        Set shpObjVis = pagObjVis.Shapes.Item(intCounter)
        If shpObjVis.CellExists("Prop.eMail", 0) Then
            Set celObjVis = shpObjVis.Cells("Prop.eMail")
            If Len(celObjVis.ResultStr("")) > 0 Then
                Set g_MailItem = otlkObjApp.CreateItem(olMailItem)
                With g_MailItem
                    . Recipients.Add celObjVis.ResultStr("")
                    .Subject = "Psssst... 2007 is just about here."
                    .Body = "Come on back and join the celebration!"
                    .Send
                End With
            End If
        End If
    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