Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5968345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:04:37+00:00 2026-05-22T20:04:37+00:00

I researched the ItemAdd event and created a class module that follows the example.

  • 0

I researched the ItemAdd event and created a class module that follows the example. My macro won’t fire when I receive new messages.

The macro parses data within the email and saves it to an Excel file. It is in it’s own module. I can run it manually.
I am trying to have it append new data each time I receive a new copy of the specific message.
I have a rule that forwards these emails into a special folder, Folder X, where I want the code to search for new messages.

My code in a class module.

Public WithEvents myOlItems As Outlook.Items

Public Sub Initialize_handler()

    ' Reference the items in the Inbox. Because myOlItems is declared
    ' "WithEvents" the ItemAdd event will fire below.
    Set myOlItems = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders("Folder X").Items
End Sub

Private Sub myOlItems_ItemAdd(ByVal Item As Object)

    Dim objMail As Outlook.MailItem
    Dim count As Integer
    Dim myTitlePos As Integer
    Dim myTitleLen As Integer
    Dim myVarPos As Integer
    Dim myVarLen As Integer
    Dim strPrice As String
    Dim strYear As String
    Dim myVarCRLF As Integer
    Dim myDate As Date
    Dim newLineTest As String 

    ' Check to make sure it is an Outlook mail message, otherwise
    ' subsequent code will probably fail depending on what type
    ' of item it is.
      
    If TypeName(Item) = "MailItem" Then

       'This is where all the working data parsing takes place.

    End If

End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:04:38+00:00Added an answer on May 22, 2026 at 8:04 pm

    Just a sanity check here… have you created an instance of this class?

    i.e. something like:

    Dim c As MyClass
    Private Sub Application_Startup()
        c = New MyClass
        ' If you don't rename Initialize_handler, you'll need:
        ' c.Initialize_handler
    End Sub
    

    in ThisOutlookSession…

    I expect you’ll also be wanting to change Initialize_handler to Class_Initialize unless you want to have to make an explicit call to it…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.