'How can I have the Select Case choose between 2 Strings?

I created a Select Case with multiple locations that choose an Outlook form based on the user's location. I now have to add an additional String, as the users may have access to multiple mailboxes in Outlook.

I want the VBA to determine which mailbox to use for the users in LA as well as in Houston. For example:

  1. Case "Blue" (user) has access to the Region = "Toast Los Angeles"
  2. Case "Red" (user) has access to the Region = "losangeles toast test"
  3. Both users should be able access FormTemplate = "IPM.Note._LA Pres Center Job Complete Notification - IBD"
  4. Both mailboxes are the same, but just different naming conventions set up in our environment (which I don't have access to changed)
  5. The same would be used in the Houston Location

I tried doing an If statement within the Case Statement, but I couldn't get it to trigger. I also tried to duplicate the LA Case and put a different String and that didn't work either.

Sub JobCompletion()
Dim Inbox As Object
Dim MyItem As Object
Dim Region As String
Dim RegionB As String
Dim FormTemplate As String

'This code was replaced by Environ("UserName") to be compatible with Win 10
'Select Case fOSUserName()
Select Case Environ("UserName")
  
  'Set up site according to username for LA
  Case "blue", "red", "pink"
  Region = "Toast Los Angeles"
  RegionB = "losangeles toast test"
  FormTemplate = "IPM.Note._LA Pres Center Job Complete Notification - IBD"

 'Set up site according to username for HOU
  Case "black", "brown", "gree"
  Region = "Toast Houston"
  RegionB = "houston toast test"
  FormTemplate = "IPM.Note._HOU Pres Center Job Complete Notification - IBD"
  
  Case Else
  MsgBox "Please Contact Jacob X to add you to the Macro"
  Exit Sub
  
  End Select
  
        'Check Version of Outlook (2007 vs 2010)
            If Outlook.Application.Version = "12.0.0.6680" Then
                On Error GoTo FolderError:
                Set Inbox = Outlook.Application.GetNamespace("MAPI").Folders("Mailbox - " & Region)
                On Error Resume Next
            Else
                On Error GoTo FolderError:
                Set Inbox = Outlook.Application.GetNamespace("MAPI").Folders(Region).Folders("Inbox")
                On Error Resume Next
            End If
    
            'Open Form From Folder (The Inbox =)
            Set MyItem = Inbox.Items.Add(FormTemplate)
            MyItem.SentOnBehalfOfName = Region
            MyItem.Display
  
Set Inbox = Nothing
Set MyItem = Nothing
     
Exit Sub

FolderError:
MsgBox "Could not connect to the " & Region & " Shared Mailbox. Please add the folder to your Outlook profile to use this macro. Reminder the Pres- part of the email has been removed."


End Sub


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source