VBA Code - Extracting Subject line text into various Excel columns

MHamid

Active Member
Joined
Jan 31, 2013
Messages
472
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hello,

I've been searching for a few days and trying to manipulate some outlooks codes for my project without any success. I can't get passed locating the outlook folder needed in a shared mailbox.

This is what I need the Outlook VBA code to do.
1) Shared mailbox name "Team Tracking"
2) Find "Inbox"
3) Find Subfolder "Delivery"
4) Find Subfolder "Hamid"

Once the VBA code finds the subfolder "Hamid", it will take the first e-mail, look in the subject line and extract the text in that field into an Excel Spreadsheet "Template" located on the Desktop. This will be done for however many e-mails there are in the "Hamid" folder.

The subject line will have the following format:
ABC DEF Delivery 3/17/2017 - DEF0123456789A1_17Feb_C COLON


The Template will look like:
Column A = Count
Column B = CASEID
Column C = Delivery Type
Column D = Date of Completion
Column E = Delivery Date
Column F = Period of Review
Column G = Name


Subject line should be broken down like so into the Excel Template:
Count = # of line Item (1,2,3, etc.)
CASEID = DEF0123456789A1
Delivery Type =
Date of Completion = 3/17/2017
Delivery Date = Date per E-mail
Period of Review = 17Feb
Name = C COLON


Is it possible to create an Outlook VBA code to extract data from the subject line and split that into specific cells in Excel?


Below is the code I have so far:

Code:
Sub Retrieve_AARRecon()

'Outlook folder- deifinitions
    Dim myItem As MailItem
    Dim myFolder As Folder
    Dim myNamespace As NameSpace
    Set myNamespace = Application.GetNamespace("MAPI")
'Put your folders name here
'1st one is the mailbox name
'2nd is the 'inbox folder'
    Set myFolder = myNamespace.Folders("AAR Team Tracking")
    Set myFolder = myFolder.Folders("Inbox")
    Set myFolder = myFolder.Folders("Delivery - Correspondent Bank AARs")
    Set myFolder = myFolder.Folders("CB")

'Destination file
    Dim resFile As String
        resFile = "H:\jpmDesk\Desktop\Recon\Projects\2017\AAR Macro\AAR Recon Template.xlsx"
    Dim ff As Byte
        ff = FreeFile()

'Opening Template File ... will append data
    Open resFile For Append As #ff

'Find the next empty line of the worksheet
    rCount = xlSheet.Range("A" & xlSheet.Rows.Count).End(-4162).Row
    rCount = rCount + 1
    
 'Collect Outlook Fields
    For Each myItem In myFolder.Items
    StrColE = olItem.ReceivedTime
    
    
    
    Next
    Close #ff
End Sub
 
Last edited:

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,215,257
Messages
6,123,916
Members
449,133
Latest member
rduffieldc

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top