• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 331
  • Last Modified:

Outlook View Control

Hello,

In my script, I have code that indicates what folder to look at for my Outlook View Control.  

Set oCSIFolder = oNS.Folders("Public Folders").Folders("All Public Folders").Folders("Tasks-FramesII")

This works in 2007.  Since upgrading to 2010, it doesn't work.  2010 shows the address of the public folder differently like this:

\\Public Folders - Joel@myworkdomain.com\All Public Folders\Tasks-FramesII

I have people working in 2007 and 2010.  I need to come up with a fix that will work in both environments.

Thanks,
Joel
0
Genius123
Asked:
Genius123
  • 3
  • 2
1 Solution
 
prashanthdCommented:
Can you post the script? Secondly "Joel@myworkdomain.com" is this static?
0
 
Genius123Author Commented:
Joel@myworkdomain.com will change depending on the user.  It seems to you would need to check what outlook version you were running in the code?  I will post the code.  THanks.
Sub CommandButtonOpenMain_Click()
	Dim oParent
	Dim oNS
	Dim oFolder

	On Error Resume Next

if JobYearNow - JobYear < 2 then
  	Set oNS = Nothing
  	Set oNS = Application.GetNamespace("MAPI")
	
	set oFolder = Nothing
	Set oFolder = oNS.Folders("Public Folders").Folders("All Public Folders").Folders("Tasks-FramesII")
	Set oParent = Nothing
	Set oParent = oFolder.Items.Find("[JobNumber] = '" & Item.UserProperties("JobNumber").Value & "' and " & "[Message Class] = 'IPM.Task.Monster'")
	else
  	Set oNS = Nothing
  	Set oNS = Application.GetNamespace("MAPI")
	
	set oFolder = Nothing
	Set oFolder = oNS.Folders("Public Folders").Folders("All Public Folders").Folders("Tasks-FramesII").Folders(JobYearNow-(JobYearNow - JobYear)&"_Archive")
	Set oParent = Nothing
	Set oParent = oFolder.Items.Find("[JobNumber] = '" & Item.UserProperties("JobNumber").Value & "' and " & "[Message Class] = 'IPM.Task.Monster'")
end if

	oParent.Display
	Item.Close 0	'olSave = 0, olDiscard = 1

	set oFolder = Nothing
	Set oParent = Nothing

End Sub

Open in new window

0
 
prashanthdCommented:
The following code will tell Outlook Version
Const HKEY_CLASSES_ROOT    = &H80000000
Const HKEY_CURRENT_USER    = &H80000001
Const HKEY_LOCAL_MACHINE   = &H80000002
Const HKEY_USERS     = &H80000003
Const HKEY_CURRENT_CONFIG  = &H80000005
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "Outlook.Application\CurVer"
strValueName = ""
oReg.GetStringValue HKEY_CLASSES_ROOT, strKeyPath, strValueName, strValue

If Replace(strValue,"Outlook.Application.","") = "12" Then 
    WScript.Echo "2007"
ElseIf Replace(strValue,"Outlook.Application.","") = "12" Then 
    WScript.Echo "2010"
End If

Open in new window

0
 
prashanthdCommented:
Change Line No 14

ElseIf Replace(strValue,"Outlook.Application.","") = "14" Then
0
 
Genius123Author Commented:
THanks.
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

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