Avatar of Dale James
Dale James

asked on 

Excel VBA: Convert from Early Binding to Late Binding

Hello Team,

I have inherited the follow code which is used to record the details contained within each email received into the Plan Setup mailbox.

The code is currently coded for early binding but can you please advise where and what equivalent code should be used to convert to late binding?

Sub PlanSetup()


Dim OutApp As Outlook.Application
Dim OutlookNamespace As Namespace
Dim Folder As MAPIFolder
Dim OutlookMail As Variant
Dim i As Integer
Dim OutApp As Outlook.Application
Dim FlagCol As String
Dim fldSpamDigest As Outlook.MAPIFolder
   
Set OutlookApp = New Outlook.Application
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI"


Set Folder = OutApp.GetNamespace("MAPI").Folders("Plansetup").Folders("Inbox") '.Folders("1 Plan Setup Enquiries")




Sheets(1).Select


i = 1


For Each OutlookMail In Folder.Items
   
Range("A1").Offset(i, 0).Value = OutlookMail.Subject
       
       
       
        If InStr(1, OutlookMail.Subject, "Recall") > 0 Or InStr(1,    OutlookMail.Subject, "Undeliver") > 0 Or InStr(1,             OutlookMail.Subject, "delay") > 0 Then
       


       
        Range("B1").Offset(i, 0).Value = "=Today()"
        Range("C1").Offset(i, 0).Value = "Recall"
        Range("D1").Offset(i, 0).Value = OutlookMail.UnRead
        Range("E1").Offset(i, 0).Value = 0
 
       
    Else
       
        Range("B1").Offset(i, 0).Value = OutlookMail.ReceivedTime
        Range("C1").Offset(i, 0).Value = OutlookMail.SenderName
        Range("D1").Offset(i, 0).Value = OutlookMail.UnRead
        Range("E1").Offset(i, 0).Value = OutlookMail.FlagStatus
    
    End If
       
    i = i + 1
    Next OutlookMail


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




End Sub

Open in new window


Thank you in advance.

Sincerely

Dale

OutlookVBAMicrosoft ExcelMicrosoft Office

Avatar of undefined
Last Comment
Bill Prew

8/22/2022 - Mon