Link to home
Start Free TrialLog in
Avatar of ChuckRush
ChuckRush

asked on

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
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

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

Avatar of ChuckRush
ChuckRush

ASKER

Chris i am still getting a 'does not support this property' on the line
set objItem=Item.GetInspector.ModifiedPages("HelpDeskTicket").Controls("Body")
LIke I said i'm not competent ;o)

But in that case try:

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

Chris
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
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

ASKER CERTIFIED SOLUTION
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

Thanks again Chris.