Well I'm kind novice when it comes to Excel VBA + Outlook. I've imported Sender, Subject, ReceivedTime from outlook on to a sheet in excel for few emails. now I've added a Ref column in the worksheet which has the text concatenated of all the 3 headers (=Sender&Subject&ReceivedTime). Now I'm trying to open each email from the list I had prepared. in outlook I've added a user defined column which has the formula "[From] & [Subject] & [Received]". I did this to create a unique ID for each email in the inbox. Now I wrote a code to loop through the list in excel Ref column, take each cell value and then find the same in outlook. what I want is once an email is found, that email has to be displayed and then move onto the next cell in the ref column in the excel sheet. below is the code I've written:

Option explicit

Dim OutlookApp As Object
Dim OutlookNamespace As Object
Dim Folder As Object
Dim OutlookMail As Object
Dim OutlookItem As Object
Dim i As Long, j As Long
Dim Dt As Date
Dim ref As String

Sub AllocateEmails()

On Error Resume Next

Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookNamespace = OutlookApp.GetNamespace("mapi")
Set Folder = OutlookApp.Session.Folders(Sheet3.Range("MailBox_Name").Value).Folders("Inbox")
Set OutlookItem = OutlookApp.Items


For i = 2 To Application.CountA(Sheet2.Columns(1))

If Sheet2.Cells(i, 10).Value <> "Allocated" Then

ref = Sheet2.Cells(i, 1).Value & Sheet2.Cells(i, 2).Value & Sheet2.Cells(i, 3).Value


Set OutlookMail = OutlookItem.Find("[Unique Ref] = " & """" & ref & """")

If Not (OutlookMail Is Nothing) Then

OutlookMail.Display

Else


End If

End If

Next i




Set OutlookMail = Nothing
Set Folder = Nothing
Set OutlookNamespace = Nothing
Set OutlookApp = Nothing

MsgBox "Done"

End Sub


my problem is this isn't workin. don't know whats wrong.

Can any one help me.