Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get MSAccess to Check for New Emails in Outlook 1

Status
Not open for further replies.

GammelNok

Programmer
Jun 21, 2002
32
0
0
US
I have a need for automatically check for emails in outlook, then import Subject and Body text into Access
Does anyone have a good solution

Thanks

Hans
 
Automation is the answer.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set MyFolder = myNameSpace.Folders("Personal Folders")("Inbox")
For Each myMailItem in MyFolder.Items
If myMailItem.Unread Then
mySubject = mymailItem.Subject
myBody = myMailItem.Body
'do whatever you like with them
' .......
myMailItem.Unread=False
End If
Next
Set myFolder = Nothing
Set myNameSpace = Nothing
Set myOlApp = Nothing



Run the code from the Timer event of a form and it will check the mapi folder regularly...

Good luck

[pipe]
Daniel Vlas
Systems Consultant

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top