When my rule runs, the script below runs, and it has been working fine, but when multiple emails for that rule come through, I'm getting a 

> 
> "runtime error 9 subscript out of range message" 
> 
> 
> 

when I click "debug," it highlights this line:

```
sFileName = varAddress(10)

```

Here is my code in its entirety.

```
Private Function CreateDir(FldrPath As String)
    Dim Elm As Variant
    Dim CheckPath As String

    CheckPath = ""
    For Each Elm In Split(FldrPath, "\")
        CheckPath = CheckPath & Elm & "\"

        If Len(Dir(CheckPath, vbDirectory)) = 0 Then
            MkDir CheckPath
            Debug.Print CheckPath & " Folder Created"
        End If

        Debug.Print CheckPath & " Folder Exist"
    Next   
End Function

Sub SaveEagleView(itm As Outlook.MailItem)
    Dim strSubject As String, strExt As String
    Dim objAtt As Outlook.Attachment
    Dim saveFolder As String
    Dim NextFriday As Date
    Dim sFileName As String
    Dim varAddress As Variant
    Dim City As Variant
    Dim fdObj As Object
    Dim JobArea As String
    Dim JobCity As Variant
    Dim myPath As String
    Dim myFinalPath As String
    Dim objMsg As MailItem
    Dim sFileExt As String

    Set objMsg = Application.CreateItem(olMailItem)

    Dim enviro As String
    NextFriday = Date + 8 - Weekday(Date, vbFriday)
    Set myfolder = Outlook.ActiveExplorer.CurrentFolder
    Set fdObj = CreateObject("Scripting.FileSystemObject")

    'Loop through emails in folder
    For i = 1 To myfolder.Items.Count
        Set myitem = myfolder.Items(i)
        msgtext = myitem.Body

        'Search for Specific Text
        delimitedMessage = Replace(msgtext, "Address: ", "###")
        delimitedMessage = Replace(delimitedMessage, ",", "###")
        varAddress = Split(delimitedMessage, "###")

        'Assign the job address from email to variable
        sFileName = varAddress(10)
        JobCity = LTrim(varAddress(11))
        On Error Resume Next

        'Define office area based on job city

        If JobCity = "Panama City" Or JobCity = "Mexico Beach" Or JobCity = "Panama City Beach" Or JobCity = "Lynn Haven" Or JobCity = "Port Saint Joe" Then
            JobArea = "Panama"
        ElseIf JobCity = "Daytona Beach" Or JobCity = "Port Orange" Or JobCity = "Deltona" Or JobCity = "Ormond Beach" Or JobCity = "Deland" Then
            JobArea = "Daytona"
        ElseIf JobCity = "Orlando" Then
            JobArea = "Orlando"
        ElseIf JobCity = "Jacksonville" Or JobCity = "Jacksonville Beach" Then
            JobArea = "Jacksonville"
        Else
            JobArea = JobCity
        End If

        For Each objAtt In itm.Attachments
            saveFolder = "C:\Users\admin\OneDrive\Documents\EagleView\" & Format$(NextFriday, "yyyy-mm-dd") & "\" & JobArea & "\"

            CreateDir saveFolder
            If Right(objAtt.FileName, 3) = "PDF" Then
                sFileExt = ".pdf"
                File = saveFolder & sFileName & sFileExt
                objAtt.SaveAsFile File
            End If

            With objMsg
                .To = "Careers@Email.com"
                .CC = "CustomerService@Email.com"
                .Subject = "New EagleView Needs Uploaded"
                .BodyFormat = olFormatPlain
                .Body = "A new EagleView has been received for the " & JobArea & " office. The file name is " & sFileName & " and needs to be uploaded. Thanks!"
                .Send
            End With

            Set objMsg = Nothing
            On Error Resume Next
        Next
    Next

    Set objAtt = Nothing
End Sub

```

Thanks for your help!

Edit to add more info:

The subject of the email is this:

> 
> FW: EagleView Report 26103101 - 123 Apple Ln, City, State (Premium, $40.00, 4014 sq ft)
> 
> 
> 

There is also this in the body of the email:

• Report ID: 26103101 (Premium, $40.00, 4014 sq ft)
• Address: 123 Apple Ln, City, State 32174-8768

What I need extracted into a variable is the street address, and the city, all other info is irrelevant for this rule