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 7585379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:09:41+00:00 2026-05-30T19:09:41+00:00

I’m trying a different approach to something that I was working on the other

  • 0

I’m trying a different approach to something that I was working on the other day. At work, we use Outlook 2010 and receive emails with .XLSX attachments throughout the day. I’m trying to figure out how to use VBA in Outlook to check incoming emails for attachments, then if the attachment count is > 0, test the attachment and if it’s a spreadsheet, update tblOutlookLog with the senders address book information. This is only my 2nd or third day experimenting with VBA outside of MS Access and I’m fumbling in the dark trying to figure out syntax. I’ve posted the code below from Outlook below. I get an error in the olInbox_ItemAdd(ByVal Item As Object) section at the .Subject line stating that it is an “invalid or unqualified reference”. I apologize in advance in it’s sloppy. Thank you for any assistance or direction.

Option Explicit

Private WithEvents InboxItems As Outlook.Items
    Dim olns As NameSpace
    Dim olInbox As MAPIFolder
    Dim olItem As Object
    Dim olAtmt As Attachment
    Dim db As DAO.Database
    Dim rst As DAO.Recordset

    Const strdbPath = "\\FMI-FS\Users\sharp-c\Desktop\"
    Const strdbName = "MSOutlook.accdb"
    Const strTableName = "tblOutlookLog"

Private Sub Application_Startup()
    Set olns = GetNamespace("MAPI")
    Set olInbox = olns.GetDefaultFolder(olFolderInbox).Items
    Set db = OpenDatabase(strdbPath & strdbName)
    Set rst = db.OpenRecordset(strTableName, dbOpenDynaset)
End Sub

Private Sub Application_Quit()
    On Error Resume Next
    rst.Close
    db.Close
    Set olns = Nothing
End Sub


Private Sub olInbox_ItemAdd(ByVal Item As Object)
    Dim olItem As Outlook.MailItem
    Dim olAtmt As Outlook.Attachment
    Dim strFoldername As String
    Dim strFilename As String
    Dim i As Integer
    i = 0

    For Each olItem In olInbox.Items
      For Each olAtmt In olItem.Attachments
        If olItem.olAtmt.Count > 0 Then
            If Right$(olAtmt.FileName, 5) = ".xlsx" Then
                strFilename = "\\FMI-FS\Users\sharp-c\Desktop\Test" & olAtmt.FileName
                olAtmt.SaveAsFile strFilename
                i = i + 1
                    rst.AddNew
                    rst!Subject = Left(.Subject, 255)
                    rst!Sender = .Sender
                    rst!FromAddress = .SenderEmailAddress
                    rst!Status = "Inbox"
                    rst!Logged = .ReceivedTime
                    rst!AttachmentPath = strFilename
                    Next
                    rst.Update
            End If

         Next olAtmt
         Next olItem

        Set olAtmt = Nothing
        Set olItem = Nothing
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-30T19:09:43+00:00Added an answer on May 30, 2026 at 7:09 pm

    You need to prefix items with the object:

    rst!Subject = Left(olItem.Subject, 255)
    

    And so forth. I think you may have removed With at some stage.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

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.