Open an outlook email by Subject on MS Access linked table with VBA

Status
Not open for further replies.

Juliano

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
Hi everyone
I linked my Inbox folder to MS access table. It means that every time I open my access table, it is updated as per current emails in my inbox - It is already an built in feature on MS Access.

I would like to know on how from my MS Access, using the Subject field in my linked table I open the same message straight in Outlook email by VBA.

Thanks in advance
 

Juliano

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
When using the built in option to link my access table to outlook folder, it doesn't show any ID field for email. So manually there is no way to get this field from Outlook that's why my only option was the Subject field.
Actually the record exists on Outlook due its a linked table to Outlook data.
I just don't know how to proceed to make this magic. I mean, this automation by VBA I need assistance from experts.
 

Juliano

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
Is there a way we can import all outlook table fields so we can get the proper email ID avoiding duplication?
I really don't know how to proceed.
 

Juliano

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
Scratching the helper, I could develop the code below.
Now my problem is the EntryID field that I don't have on my Access table because when using the assistant, the build in feature don't retrieve this field.
My problem now is how to import/link this field

Code:
Sub openOutlookEmailByAccess()
    Dim OutLookApp As New Outlook.Application
    Dim OutLookNameSpace As Outlook.NameSpace
    Dim OutLookMail As Outlook.MailItem
    Set OutLookNameSpace = OutLookApp.GetNamespace("MAPI")
    OutLookNameSpace.Logon
    Set OutLookMail = OutLookNameSpace.GetItemFromID("00000000B92893D4C199E74592434EEA5D4818860700B38917A16466634586AD214BF5FA94F600A17CBD800D0000B38917A16466634586AD214BF5FA94F600A17CBDBAC70000")
    OutLookMail.Display
End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
As long as you have received dates, you should be able to get unique messages using Find or Restrict.
 

Juliano

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
Well, I'm trying to use your suggestion as per code below. But is saying that a variable was not set. Err 91. Why is not working?

Code:
Sub openOutlookEmailByAccess()
    Dim OutLookApp As New Outlook.Application
    Dim OutLookNameSpace As Outlook.NameSpace
    Dim OutLookMail As Outlook.MailItem
    Dim OutLookItems As Outlook.Items
    Dim OutLookRestItems As Outlook.Items
    Dim strFilter As String
   
    Dim OutLookInboxFolder As Outlook.MAPIFolder
    Dim OutLookSrcFolder As Outlook.MAPIFolder
    Dim strSrcSubject As String
    Dim strSrcReceived As String
   
    Set OutLookNameSpace = OutLookApp.GetNamespace("MAPI")
    Set OutLookInboxFolder = OutLookNameSpace.GetDefaultFolder(olFolderInbox)
   
    Set OutLookSrcFolder = OutLookInboxFolder.Folders("@04-COMPLETED")
   
    OutLookNameSpace.Logon
    strSrcSubject = "[Subject]= 'Testing Tips'"
    strSrcReceived = "[Received] ='" & Format("03/11/2017 08:06:19", "ddddd h:mm:ss AMPM") & "'"
   
    strFilter = strSrcSubject & " And " & strSrcReceived
   
    Set OutLookItems = OutLookSrcFolder.Items
    OutLookRestItems = OutLookItems.Restrict(strFilter)
   
End Sub
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
E Unable to open Outlook 2010 after adding new email account Using Outlook 4
Z Outlook 2007, clicking email addresses fails to open Contact Using Outlook 0
D Outlook VBA to open Excel attachment and send recipient's email address to a workbook cell? Using Outlook 4
S Pre populate subject + body + attachment to already open email in outlook 2007 Using Outlook 2
D Outlook 2010: Change the font for the area at the top of an open email. Using Outlook 1
D Outlook 2013 Doesn't Send email from Web Page Unless Outlook Is Open Using Outlook 2
mrje1 mailto links in browsers don't open up outlook email Using Outlook 2
M Outlook 2007 "cannot open your default email folders.microsoft exchange is not available" on XP is n Using Outlook 1
G I can't open a URL link in from my email- Using Outlook 2007-Vista- AVG anti-virus Using Outlook 1
E Double clicking on from email address does no longer open corresponding contact in Outlook 2007 Using Outlook 7
J Macro to open email (like double click) in Outlook Outlook VBA and Custom Forms 4
witzker Open Contact missing in Outlook 2019 Using Outlook 2
A How to open a specific link automatically with outlook 2016 Outlook VBA and Custom Forms 6
H Upon opening Outlook, make my popmail inbox open instead of outlook.com inbox Using Outlook 1
sahameed82 SharePoint calendar directly open in Outlook Using Outlook 0
C Outlook 2016/2019 hangs after being open for an extended period Using Outlook 4
J How to open OST file in Outlook 2019 & 2016 Using Outlook 1
C Can't Open Outlook 365 Using Outlook 0
M outlook won't open! Using Outlook 1
A How to open a specific link automatically with outlook Outlook VBA and Custom Forms 13
S Outlook 2010 Cannot Open Attachments Using Outlook 14
N open the hyperlink in Outlook directly instead of browser Using Outlook 1
S Outlook does not open the .pst file created by the Outlook Using Outlook 5
A open Outlook with multiple windows. Using Outlook 0
G Can't open .pst. Message could not access default folder (Outlook 2010 (.pst). Before that was backi Using Outlook 0
I Outlook 2010, 2013 will not open .msg or .eml files Using Outlook.com accounts in Outlook 1
Diane Poremsky Outlook VBA: Work with Open Item or Selected Item New Slipstick.com Articles 0
O Windows 10 x64 Outlook 2013 - URL does not open (anymore) Using Outlook 3
Diane Poremsky Outlook 2013: Control Panel Mail Won't Open New Slipstick.com Articles 0
Diane Poremsky Outlook Links Won't Open In Windows 10 New Slipstick.com Articles 1
L Outlook 2013 won't open MS Office attachments Using Outlook 1
Diane Poremsky Open Shared Mailboxes in Outlook on the Web New Slipstick.com Articles 0
V Cannot start Outlook. Cannot open the Outlook window. Using Outlook 8
O Outlook 2003 can't open contacts. Using Outlook 2
G Outlook calendar entry corrupted. Constant pop up when you open outlook. Unable to delete or remove. Using Outlook 2
J Outlook won't open. PST file busy. Using Outlook 3
M Cannot start MS Office Outlook Cannot open the Outlook window Using Outlook 2
Gareth Outlook Task Will not open. Using Outlook 5
M Can't open same msg file more than once at the same time in Outlook 2010 Using Outlook 7
B What is the best way to use Outlook address book to select customer and then open Excel Outlook VBA and Custom Forms 22
J VBS Script (macro) for word to open Outlook template. Outlook VBA and Custom Forms 2
F Cannot open extracted .msg files from outlook Outlook VBA and Custom Forms 1
L Trying to open contacts pst. file in outlook 365 Using Outlook 3
V Open Outlook Calendar and Tasks views with Folder pane off Using Outlook 2
L Outlook 2007 Open Folder From a Contact Using Outlook 22
B Add-in "always enabled" but Outlook 13 won't open Using Outlook 7
P open reminders missing after copying outlook pst file Using Outlook 2
L Outlook 2007 Macro Open Contact Folder Using Outlook 7
Lucas attachments in outlook don't open, when Icloud is connected Using Outlook 0
T Outlook 2010 Very Slow To Open Recently Using Outlook 9

Similar threads

Top