Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 458
  • Last Modified:

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
0
ChuckRush
Asked:
ChuckRush
  • 4
  • 4
1 Solution
 
Chris BottomleyCommented:
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
 
Chris BottomleyCommented:
LIke I said i'm not competent ;o)

But in that case try:

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

Chris
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

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

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now