Results 1 to 5 of 5
  1. #1
    sdc1234 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    89

    Access and Outlook


    I am trying to save all of my email tracking into a database in Access for about 1500 people , is this possible? If so, would I have to enter them one by one or is there an easier way? Thank you

  2. #2
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    If there's a lot of them, I'm sure there's an easier way.

    For instance, assuming your emails are currently stored in Outlook, you could use VBA from within Access to pull them over from Outlook, or VBA from Outlook to push them over to Access. Either direction, you'll have to work out the syntax to open the other application and copy the emails.

    I've seen specific info here on how to do that to/from Excel, but i haven't seen much on Outlook. Then again, I haven't been looking for it.

  3. #3
    live2ride is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2012
    Posts
    70
    below code will import emails from outlook to access

    Private Function emailCount()
    importFromOutlook
    End Function

    Sub importFromOutlook()
    On Error GoTo err_LogError

    Dim rs As DAO.Recordset
    Set rs = CurrentDb.OpenRecordset("table")
    Dim outlookApp As Outlook.Application
    Set outlookApp = CreateObject("outlook.Application")
    Dim inboxMain As Outlook.MAPIFolder
    Set inboxMain = outlookApp.GetNamespace("MAPI").GetDefaultFolder(o lFolderInbox)
    '' below is if your email is stored in sub folder
    Dim inboxSubfolder1 As Outlook.MAPIFolder
    Set inboxSubfolder1 = inboxMain.Folders("sub folder 1")
    Dim inboxSubfolder2 As Outlook.MAPIFolder
    Set inboxSubfolder2 = inboxSubfolder1.Folders("sub folder 2")
    Dim InboxItems As Outlook.Items
    Set InboxItems = inboxSubfolder2.Items ''change to 'inboxMain' if email is in main inbox folder
    Dim emails As Object

    For Each emails In InboxItems
    'if emails.unread then ' if emails are read or unread
    With rs
    .AddNew
    !Subject = emails.Subject
    !Contents = emails.Body
    !Received = emails.ReceivedTime
    !Created = emails.SentOn
    ' you can add additional fields as you want
    .Update

    ''''''' below updates your emails in outlook, i prefer to do something to emails like change category so you know you have imported this email and prevent duplicates
    emails.UnRead = False
    emails.Categories = "imported by access"
    ' emails.Importance = 0
    emails.TaskCompletedDate = Now()
    emails.Save
    emails.move inboxSubfolder1 ''' if you want to move your emails to another folder

    End With
    'end if
    Next

    ''''' when going through many emails something gets broken and only few emails are imported
    If InboxItems.count <> 0 Then
    Call emailCount
    End If

    rs.Close
    Set outlookApp = Nothing
    Set inboxMain = Nothing
    Set inboxSubfolder1 = Nothing
    Set inboxSubfolder2 = Nothing
    Set emails = Nothing
    Set rs = Nothing


    Exit_LogError: ' Label to resume after error.
    Exit Sub
    err_LogError:
    MsgBox Err.Number & Err.Description

    End Sub

  4. #4
    sdc1234 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    89
    Quote Originally Posted by live2ride View Post
    below code will import emails from outlook to access

    Private Function emailCount()
    importFromOutlook
    End Function

    Sub importFromOutlook()
    On Error GoTo err_LogError

    Dim rs As DAO.Recordset
    Set rs = CurrentDb.OpenRecordset("table")
    Dim outlookApp As Outlook.Application
    Set outlookApp = CreateObject("outlook.Application")
    Dim inboxMain As Outlook.MAPIFolder
    Set inboxMain = outlookApp.GetNamespace("MAPI").GetDefaultFolder(o lFolderInbox)
    '' below is if your email is stored in sub folder
    Dim inboxSubfolder1 As Outlook.MAPIFolder
    Set inboxSubfolder1 = inboxMain.Folders("sub folder 1")
    Dim inboxSubfolder2 As Outlook.MAPIFolder
    Set inboxSubfolder2 = inboxSubfolder1.Folders("sub folder 2")
    Dim InboxItems As Outlook.Items
    Set InboxItems = inboxSubfolder2.Items ''change to 'inboxMain' if email is in main inbox folder
    Dim emails As Object

    For Each emails In InboxItems
    'if emails.unread then ' if emails are read or unread
    With rs
    .AddNew
    !Subject = emails.Subject
    !Contents = emails.Body
    !Received = emails.ReceivedTime
    !Created = emails.SentOn
    ' you can add additional fields as you want
    .Update

    ''''''' below updates your emails in outlook, i prefer to do something to emails like change category so you know you have imported this email and prevent duplicates
    emails.UnRead = False
    emails.Categories = "imported by access"
    ' emails.Importance = 0
    emails.TaskCompletedDate = Now()
    emails.Save
    emails.move inboxSubfolder1 ''' if you want to move your emails to another folder

    End With
    'end if
    Next

    ''''' when going through many emails something gets broken and only few emails are imported
    If InboxItems.count <> 0 Then
    Call emailCount
    End If

    rs.Close
    Set outlookApp = Nothing
    Set inboxMain = Nothing
    Set inboxSubfolder1 = Nothing
    Set inboxSubfolder2 = Nothing
    Set emails = Nothing
    Set rs = Nothing


    Exit_LogError: ' Label to resume after error.
    Exit Sub
    err_LogError:
    MsgBox Err.Number & Err.Description

    End Sub

    am I to create a macro?

  5. #5
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Macros don't look like that. That's VBA. It could go behind a button on a form, or in a ribbon if you know how and want to put it there.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 11
    Last Post: 05-20-2014, 11:32 AM
  2. Access - Outlook
    By Paris1988 in forum Access
    Replies: 3
    Last Post: 04-20-2012, 10:32 AM
  3. Assigning Outlook task from shared Outlook mailbox
    By Remster in forum Programming
    Replies: 2
    Last Post: 11-16-2011, 04:38 AM
  4. Outlook to Access
    By Aubreylc in forum Import/Export Data
    Replies: 1
    Last Post: 01-25-2010, 09:37 AM
  5. MS-Access into Outlook - possible?
    By techexpressinc in forum Access
    Replies: 0
    Last Post: 01-09-2009, 01:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums