Outlook Form with VB Script

Experts

I have an Outlook for the has several Combo Boxes. After the selections are made i want to create a template message and send it. I have the following code and i am getting and error telling me the the object does not support the property in line 10 (Item ....) of the following code. I am sure it is syntax but i can't seem to find an example to fit my situation.


Function Item_Send
dim objItem,  ctl, wStr
'Create BODY Text
set objItem=Item.GetInspector.ModifiedPages("HelpDeskTicket").Controls("Body")
objItem.Body =       "@title=" & Item.UserProperties.Find("txtTitle").value & vbCrLf & _
                  "@custom_2=" & Item.UserProperties.Find("txtProblemDescription").value & vbCrLf & _
                  "@category=" & Item.UserProperties.Find("cmbCategory").value & vbCrLf & _
                  "@impact=" & Item.UserProperties.Find("cmbImpact").value & vbCrLf & _
                  "@priority=" & Item.UserProperties.Find("cmbPriority").value & vbCrLf & _
                  "@custom_1=" & Item.UserProperties.Find("cmbLocation").value & vbCrLf & _
                  "@custom_3=" & Item.UserProperties.Find("txtPhoneNumber").value & vbCrLf
end Function

Thanks
ChuckRushAsked:
Who is Participating?
 
Chris BottomleySoftware Quality Lead EngineerCommented:
Your response does not indicate if you replaced references to item as it still looks to me as though it has no value when the code runs ... i.e. as I said above:


Note I am assuming that item is in scope ... if not then it is likely that item is the issue ... can you provide more info on the overall structure of the code sequencing if so?

for example may lead to replacing item with:

Current item selected in the folder of outlook
application.ActiveExplorer.Selection(1)
or
Current inspector, (open item) in outlook app
application.ActiveInspector.currentItem

Chris
0
 
Chris BottomleySoftware Quality Lead EngineerCommented:
I apologise since I am not competent with outlook forms/templates but it looks to me as though body is doubled up  ... try:

objItem = ...

Chris

Function Item_Send
dim objItem,  ctl, wStr
'Create BODY Text
set objItem=Item.GetInspector.ModifiedPages("HelpDeskTicket").Controls("Body")
objItem = 	"@title=" & Item.UserProperties.Find("txtTitle").value & vbCrLf & _
			"@custom_2=" & Item.UserProperties.Find("txtProblemDescription").value & vbCrLf & _
			"@category=" & Item.UserProperties.Find("cmbCategory").value & vbCrLf & _
			"@impact=" & Item.UserProperties.Find("cmbImpact").value & vbCrLf & _
			"@priority=" & Item.UserProperties.Find("cmbPriority").value & vbCrLf & _
			"@custom_1=" & Item.UserProperties.Find("cmbLocation").value & vbCrLf & _
			"@custom_3=" & Item.UserProperties.Find("txtPhoneNumber").value & vbCrLf 
end Function

Open in new window

0
 
ChuckRushAuthor Commented:
Chris i am still getting a 'does not support this property' on the line
set objItem=Item.GetInspector.ModifiedPages("HelpDeskTicket").Controls("Body")
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
Chris BottomleySoftware Quality Lead EngineerCommented:
LIke I said i'm not competent ;o)

But in that case try:

set objItem=Item.GetInspector.ModifiedPages("HelpDeskTicket")
objItem.Body = ...

Chris
0
 
Chris BottomleySoftware Quality Lead EngineerCommented:
Note I am assuming that item is in scope ... if not then it is likely that item is the issue ... can you provide more info on the overall structure of the code sequencing if so?

for example may lead to replacing item with:

Current item selected in the folder of outlook
application.ActiveExplorer.Selection(1)
or
Current inspector, (open item) in outlook app
application.ActiveInspector.currentItem

Chris
0
 
ChuckRushAuthor Commented:
Chris

I have attached the entire code stream. The form is an Outlook form based on a Message. It has 2 text boxes and 4 combo boxes.

Still getting an error on set objItem=GetInspector.ModifiedPages("HelpDeskTicket").Item("Body")
Option Explicit
Function Item_Open
ReadCategoryText()
ReadImpactText()
ReadPriorityText()
ReadLocationText()
End Function
Function Item_Send
dim objItem,  ctl, wStr
'Create BODY Text
set objItem=GetInspector.ModifiedPages("HelpDeskTicket").Item("Body")
objItem.Body = 	"@title=" & Item.UserProperties.Find("txtTitle").value & vbCrLf & _
		"@custom_2=" & Item.UserProperties.Find("txtProblemDescription").value & vbCrLf & _
		"@category=" & Item.UserProperties.Find("cmbCategory").value & vbCrLf & _
		"@impact=" & Item.UserProperties.Find("cmbImpact").value & vbCrLf & _
		"@priority=" & Item.UserProperties.Find("cmbPriority").value & vbCrLf & _
		"@custom_1=" & Item.UserProperties.Find("cmbLocation").value & vbCrLf & _
		"@custom_3=" & Item.UserProperties.Find("txtPhoneNumber").value & vbCrLf 
end Function
Sub ReadCategoryText()
      Const ForReading = 1
      Dim objFSO, objFile, wStr, ctl
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      ' Get Text Export from MySql FOr Category
	Set objFile = objFSO.OpenTextFile("c:\KACEData\Category.csv", ForReading)
      'Read Each Record
	'Get Field Info
	set ctl=Item.GetInspector.ModifiedFormPages("HelpDeskTicket").Controls("cmbCategory")
	Do While Not objFile.AtEndOfStream
		wStr = objFile.ReadLine
		'Get Rid of "
		wStr =Mid(wstr,2)
		wStr = Mid(wStr,1,len(wStr)-1)	
            ctl.AddItem(wStr)
      Loop
      objFile.Close
      Set objFile = Nothing
      Set objFSO = Nothing
End Sub
Sub ReadImpactText()
      Const ForReading = 1
      Dim objFSO, objFile, wStr, ctl
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      ' Get Text Export from MySql FOr Impact
	Set objFile = objFSO.OpenTextFile("c:\KACEData\Impact.csv", ForReading)
      'Read Each Record
	'Get Field Info
	set ctl=Item.GetInspector.ModifiedFormPages("HelpDeskTicket").Controls("cmbImpact")
	Do While Not objFile.AtEndOfStream
		wStr = objFile.ReadLine
		'Get Rid of "
		wStr =Mid(wstr,2)
		wStr = Mid(wStr,1,len(wStr)-1)	
            ctl.AddItem(wStr)
      Loop
      objFile.Close
      Set objFile = Nothing
      Set objFSO = Nothing
End Sub
Sub ReadPriorityText()
      Const ForReading = 1
      Dim objFSO, objFile, wStr, ctl
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      ' Get Text Export from MySql FOr Priority
	Set objFile = objFSO.OpenTextFile("c:\KACEData\Priority.csv", ForReading)
      'Read Each Record
	'Get Field Info
	set ctl=Item.GetInspector.ModifiedFormPages("HelpDeskTicket").Controls("cmbPriority")
	Do While Not objFile.AtEndOfStream
		wStr = objFile.ReadLine
		'Get Rid of "
		wStr =Mid(wstr,2)
		wStr = Mid(wStr,1,len(wStr)-1)	
            ctl.AddItem(wStr)
      Loop
      objFile.Close
      Set objFile = Nothing
      Set objFSO = Nothing
End Sub
Sub ReadLocationText()
      Const ForReading = 1
      Dim objFSO, objFile, wStr, ctl
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      ' Get Text Export from MySql FOr Location
	Set objFile = objFSO.OpenTextFile("c:\KACEData\Location.csv", ForReading)
      'Read Each Record
	'Get Field Info
	set ctl=Item.GetInspector.ModifiedFormPages("HelpDeskTicket").Controls("cmbLocation")
	Do While Not objFile.AtEndOfStream
		wStr = objFile.ReadLine
		'Get Rid of "
		wStr =Mid(wstr,2)
		wStr = Mid(wStr,1,len(wStr)-1)	
            ctl.AddItem(wStr)
      Loop
      objFile.Close
      Set objFile = Nothing
      Set objFSO = Nothing
End Sub

Open in new window

0
 
ChuckRushAuthor Commented:
Hi Chris

This code now works. I am still not comfortable that i completely understand but i am getting there.

Thanks
Option Explicit
Function Item_Open
ReadCategoryText()
ReadImpactText()
ReadPriorityText()
ReadLocationText()
End Function
Function Item_Send
dim objItem,  ctl, wStr
'Create BODY Text
set objItem =Application.ActiveInspector.CurrentItem
objItem.Body = 	"@title=" & Item.GetInspector.ModifiedFormPages("HelpDeskTicket").Controls("txtTitle").Value & vbCrLf & _
			"@custom_2=" & Item.GetInspector.ModifiedFormPages("HelpDeskTicket").Controls("txtProblemDescription").Value & vbCrLf & _
			"@category=" & Item.GetInspector.ModifiedFormPages("HelpDeskTicket").Controls("cmbCategory").Value & vbCrLf & _
			"@impact=" & Item.GetInspector.ModifiedFormPages("HelpDeskTicket").Controls("cmbImpact").Value & vbCrLf & _
			"@priority=" & Item.GetInspector.ModifiedFormPages("HelpDeskTicket").Controls("cmbPriority").Value & vbCrLf & _
			"@custom_1=" & Item.GetInspector.ModifiedFormPages("HelpDeskTicket").Controls("cmbLocation").Value & vbCrLf & _
			"@custom_3=" & Item.GetInspector.ModifiedFormPages("HelpDeskTicket").Controls("txtPhoneNumber").Value & vbCrLf 
end Function
Sub ReadCategoryText()
      Const ForReading = 1
      Dim objFSO, objFile, wStr, ctl
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      ' Get Text Export from MySql FOr Category
	Set objFile = objFSO.OpenTextFile("c:\KACEData\Category.csv", ForReading)
      'Read Each Record
	'Get Field Info
	set ctl=Item.GetInspector.ModifiedFormPages("HelpDeskTicket").Controls("cmbCategory")
	Do While Not objFile.AtEndOfStream
		wStr = objFile.ReadLine
		'Get Rid of "
		wStr =Mid(wstr,2)
		wStr = Mid(wStr,1,len(wStr)-1)	
            ctl.AddItem(wStr)
      Loop
      objFile.Close
      Set objFile = Nothing
      Set objFSO = Nothing
End Sub
Sub ReadImpactText()
      Const ForReading = 1
      Dim objFSO, objFile, wStr, ctl
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      ' Get Text Export from MySql FOr Impact
	Set objFile = objFSO.OpenTextFile("c:\KACEData\Impact.csv", ForReading)
      'Read Each Record
	'Get Field Info
	set ctl=Item.GetInspector.ModifiedFormPages("HelpDeskTicket").Controls("cmbImpact")
	Do While Not objFile.AtEndOfStream
		wStr = objFile.ReadLine
		'Get Rid of "
		wStr =Mid(wstr,2)
		wStr = Mid(wStr,1,len(wStr)-1)	
            ctl.AddItem(wStr)
      Loop
      objFile.Close
      Set objFile = Nothing
      Set objFSO = Nothing
End Sub
Sub ReadPriorityText()
      Const ForReading = 1
      Dim objFSO, objFile, wStr, ctl
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      ' Get Text Export from MySql FOr Priority
	Set objFile = objFSO.OpenTextFile("c:\KACEData\Priority.csv", ForReading)
      'Read Each Record
	'Get Field Info
	set ctl=Item.GetInspector.ModifiedFormPages("HelpDeskTicket").Controls("cmbPriority")
	Do While Not objFile.AtEndOfStream
		wStr = objFile.ReadLine
		'Get Rid of "
		wStr =Mid(wstr,2)
		wStr = Mid(wStr,1,len(wStr)-1)	
            ctl.AddItem(wStr)
      Loop
      objFile.Close
      Set objFile = Nothing
      Set objFSO = Nothing
End Sub
Sub ReadLocationText()
      Const ForReading = 1
      Dim objFSO, objFile, wStr, ctl
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      ' Get Text Export from MySql FOr Location
	Set objFile = objFSO.OpenTextFile("c:\KACEData\Location.csv", ForReading)
      'Read Each Record
	'Get Field Info
	set ctl=Item.GetInspector.ModifiedFormPages("HelpDeskTicket").Controls("cmbLocation")
	Do While Not objFile.AtEndOfStream
		wStr = objFile.ReadLine
		'Get Rid of "
		wStr =Mid(wstr,2)
		wStr = Mid(wStr,1,len(wStr)-1)	
            ctl.AddItem(wStr)
      Loop
      objFile.Close
      Set objFile = Nothing
      Set objFSO = Nothing
End Sub

Open in new window

0
 
ChuckRushAuthor Commented:
Thanks again Chris.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.