-3

I have below ReplyAll mail code, during running this code I am facing the following error:

Compile Error- User-Defined Type Not Defined

I have Pasted below Code & Try to Run this one But getting Compile Error as described above.

Sub Test()

Dim olApp As Outlook.Application
Dim olNs As Namespace
Dim Fldr As MAPIFolder
Dim olMail As Variant
Dim i As Integer

Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.GetDefaultFolder(olFolderInbox)
i = 1

For Each olMail In Fldr.Items
If InStr(olMail.Subject, "Application for Privilege Leave - Leave ID - Dev-PL-45252-4") <> 0 Then
olMail.Display

i = i + 1
End If
Next olMail
End Sub

reply-to-outlook-mail-from-excel I expect that this Macro Run without any Error.

Jitendra Singh
  • 191
  • 1
  • 8

1 Answers1

0

Follow below steps:

  1. Goto the Microsoft Visual Basic Editor where you have your code
  2. Click Tools Menu -> References
  3. In the window that opens, find Microsoft Outlook 14.0 Object Library (Version can differ on your system depending on what office version you have)
  4. Select it and click OK
  5. Now run your code.

enter image description here

Jitendra Singh
  • 191
  • 1
  • 8