S
Scott Smith
Here is the current state of my first successful VBScript for my
custom contact form. Thought I'd post it for comments, and maybe some
tips for handling this more efficiently. )
(Stripped declarations, etc.)
BTW, this is "Function Item_Open()"
Set NS = Application.GetNamespace("MAPI")
Set itmsJournal = NS.GetDefaultFolder(11).Items
Set objContact = Item
Set oPage = Item.GetInspector.ModifiedFormPages("Marketing")
Set oMailList = oPage.controls("lstSentMailings")
Set oPhoneList = oPage.controls("lstPastCalls")
' Set 'Marketing' tab current
Item.GetInspector.SetCurrentFormPage "Marketing"
' Step through journal folder items
For lItems = 1 To itmsJournal.Count Step 1
Set olTempItem = itmsJournal(lItems)
' Check to see if a match to contact is found
If olTempItem.Links.Count > 0 Then
Set objLink = olTempItem.Links.Item(1)
If objLink = objContact Then
' Add a found mailing
If InStr(1, olTempItem.Type, "Mailed", 0) > 0 Then
oMailList.addItem olTempItem.Type & " - " & _
FormatDateTime(olTempItem.Start, vbShortDate)
Else
' Add a found phone call
If InStr(1, olTempItem.Type, "Phone", 0) > 0 Then
oPhoneList.addItem olTempItem.Type & " - " & _
FormatDateTime(olTempItem.Start, vbShortDate)
' NOTE: VBA will keep overwriting this value
' (objLastCall), therefore whatever value
' is here last will be the most recent call
Set objLastCall = olTempItem
End If
End If
End If
End If
Next
' Get notes from last call
If Not IsEmpty(objLastCall) Then
oPage.controls("txtLastCallNotes").Value = objLastCall.Body
End If
There is a brief, but tolerable delay when opening a contact as
Outlook iterates thru journal entries. It's faster than the
Activities tab, but I wouldn't mind speeding it up more if possible.
)
Thanks
Scott
custom contact form. Thought I'd post it for comments, and maybe some
tips for handling this more efficiently. )
(Stripped declarations, etc.)
BTW, this is "Function Item_Open()"
Set NS = Application.GetNamespace("MAPI")
Set itmsJournal = NS.GetDefaultFolder(11).Items
Set objContact = Item
Set oPage = Item.GetInspector.ModifiedFormPages("Marketing")
Set oMailList = oPage.controls("lstSentMailings")
Set oPhoneList = oPage.controls("lstPastCalls")
' Set 'Marketing' tab current
Item.GetInspector.SetCurrentFormPage "Marketing"
' Step through journal folder items
For lItems = 1 To itmsJournal.Count Step 1
Set olTempItem = itmsJournal(lItems)
' Check to see if a match to contact is found
If olTempItem.Links.Count > 0 Then
Set objLink = olTempItem.Links.Item(1)
If objLink = objContact Then
' Add a found mailing
If InStr(1, olTempItem.Type, "Mailed", 0) > 0 Then
oMailList.addItem olTempItem.Type & " - " & _
FormatDateTime(olTempItem.Start, vbShortDate)
Else
' Add a found phone call
If InStr(1, olTempItem.Type, "Phone", 0) > 0 Then
oPhoneList.addItem olTempItem.Type & " - " & _
FormatDateTime(olTempItem.Start, vbShortDate)
' NOTE: VBA will keep overwriting this value
' (objLastCall), therefore whatever value
' is here last will be the most recent call
Set objLastCall = olTempItem
End If
End If
End If
End If
Next
' Get notes from last call
If Not IsEmpty(objLastCall) Then
oPage.controls("txtLastCallNotes").Value = objLastCall.Body
End If
There is a brief, but tolerable delay when opening a contact as
Outlook iterates thru journal entries. It's faster than the
Activities tab, but I wouldn't mind speeding it up more if possible.
)
Thanks
Scott