Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-17-2014, 05:02 AM
megatronixs megatronixs is offline take emails from outlook mailbox and folders to Access Windows 7 32bit take emails from outlook mailbox and folders to Access Office 2003
Advanced Beginner
take emails from outlook mailbox and folders to Access
 
Join Date: Aug 2012
Posts: 42
megatronixs is on a distinguished road
Default take emails from outlook mailbox and folders to Access


Hi all,

I have some code to take the emails form outlook to access database.
I was wondering how I could change the folder and subfolder where the emails should come from. Now it will take only the unread emails from the personal inbox. how can I change it to "Backup" folder that is from the: - New Line Products.

I'm also trying to show if an email has attachments or not.
Any help would be really great.

Code:
Option Compare Database
Private Sub Command14_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
'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
 
        .AddNew
        !Subject = Mailobject.Subject
        !SenderName = Mailobject.SenderName
        !To = Mailobject.To
        !Body = Mailobject.Body
        !ReceivedOn = Mailobject.ReceivedOn
        !SentOn = Mailobject.SentOn
        '!Attachments = Mailobject.Attachments 'the part that does not work
        !SenderEmailAddress = Mailobject.SenderEmailAddress 
        .Update
        Mailobject.UnRead = False
    End With
End If
Next
Set OlApp = Nothing
Set Inbox = Nothing
Set InboxItems = Nothing
Set Mailobject = Nothing
Set TempRst = Nothing
End Sub
Greetings.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to synchronize emails in certain folders when upgrade Outlook 2010 to Outlook 201 davip Outlook 0 07-30-2013 09:07 PM
Moving emails in shared mailbox to personal mailbox hlock Outlook 0 12-12-2012 02:32 PM
Outlook 2010 & Mailbox Access Stkitts11 Outlook 0 04-10-2012 06:48 AM
take emails from outlook mailbox and folders to Access Merging outlook folders and emails rudihorvath Outlook 1 03-16-2012 07:03 AM
take emails from outlook mailbox and folders to Access Outlook 07 Not Fetching Emails in Random folders miccguido Outlook 1 02-14-2012 01:51 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:53 AM.


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