Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Thread Tools Display Modes
Old 11-21-2014, 06:19 AM
megatronixs megatronixs is offline Move emails to folder in drive and store in access database Windows 7 32bit Move emails to folder in drive and store in access database Office 2003
Advanced Beginner
Move emails to folder in drive and store in access database
Join Date: Aug 2012
Posts: 42
megatronixs is on a distinguished road
Default Move emails to folder in drive and store in access database

Hi all,

I tried a few versions of exporting emails to a folder and store them in access as well. the separate versions work, but I have no clue how to combine them.
here is the code that I use from outlook:
Public Sub Command24_Click()
Dim olItem As Outlook.MailItem
Dim fName As String
Dim fPath As String
    fPath = "C:t\EmailBackup\"
    For Each olItem In ActiveExplorer.Selection
        fName = Format(olItem.ReceivedTime, "yyyy_mm_dd -") & Chr(32) & _
                Format(olItem.ReceivedTime, "HH.MM") & Chr(32) & _
                olItem.SenderName & " - " & olItem.Subject & ".msg"
        fName = Replace(fName, Chr(58) & Chr(41), "")
        fName = Replace(fName, Chr(58) & Chr(40), "")
        fName = Replace(fName, Chr(34), "-")
        fName = Replace(fName, Chr(42), "-")
        fName = Replace(fName, Chr(47), "-")
        fName = Replace(fName, Chr(58), "-")
        fName = Replace(fName, Chr(60), "-")
        fName = Replace(fName, Chr(62), "-")
        fName = Replace(fName, Chr(63), "-")
        fName = Replace(fName, Chr(124), "-")
        olItem.SaveAs fPath & fName
    Next olItem
    Set olItem = Nothing
End Sub
This is the code to save the emails to access:

Option Compare Database

Private Sub Command24_Click()

Dim TempRst As DAO.Recordset
Dim rst As DAO.Recordset
Dim OlApp As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim InboxItems As Outlook.Items
Dim Mailobject As Object
Dim db As DAO.Database
Dim dealer As Integer
Dim fName As String
Dim fPath As String
Dim olItem As Outlook.MailItem
'DoCmd.RunSQL "Delete * from tbl_outlooktemp"
Set db = CurrentDb

Set OlApp = CreateObject("Outlook.Application")
Set Inbox = OlApp.GetNamespace("Mapi").GetDefaultFolder(olFolderInbox)
Set TempRst = CurrentDb.OpenRecordset("tbl_OutlookTemp")
Set InboxItems = Inbox.Items
For Each Mailobject In InboxItems
    If Mailobject.UnRead Then
    With TempRst
        !Subject = Mailobject.Subject
        !SenderName = Mailobject.SenderName
        !To = Mailobject.To
        !Body = Mailobject.Body
        !ReceivedOn = Mailobject.ReceivedOn
        !SentOn = Mailobject.SentOn
        '!Attachments = Mailobject.Attachments
        !SenderEmailAddress = Mailobject.SenderEmailAddress
        !CC = Mailobject.CC

        Mailobject.UnRead = False
    End With
End If


Set OlApp = Nothing
Set Inbox = Nothing
Set InboxItems = Nothing
Set Mailobject = Nothing
Set TempRst = Nothing
End Sub
Any help getting this solved would be really great.

Reply With Quote

Thread Tools
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
Move emails to folder in drive and store in access database Move emails from one folder to another smiler44 Outlook 9 11-20-2014 03:02 PM
Show emails stored in a system folder (drive) in outlook megatronixs Outlook 3 10-28-2014 10:47 PM
move emails to folder with a subject that is similar megatronixs Outlook 0 10-14-2014 03:05 AM
Move emails to folder in drive and store in access database Outlook VBA rule to search email attachements and move the emails into a folder genius7 Outlook 6 09-09-2014 07:01 AM
Outlook - how to move email to K: drive augustus Outlook 0 08-11-2008 12:07 PM

Other Forums: Access Forums - Senior Forums

All times are GMT -7. The time now is 02:50 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd. is not affiliated with Microsoft