![]() |
#1
|
|||
|
|||
![]() 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 |
|
![]() |
||||
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 |
![]() |
rudihorvath | Outlook | 1 | 03-16-2012 07:03 AM |
![]() |
miccguido | Outlook | 1 | 02-14-2012 01:51 PM |