?
Solved

Reading Outlook2010 New EMail Bodies and sending pieces to Access 2010 table

Posted on 2013-06-25
5
Medium Priority
?
338 Views
Last Modified: 2013-06-26
I'm pretty good at Access vba, but havent explored much with Outlook
I get a certain amount of emails coming in mentioning jobs.  Each mail message contains a formated body that I would like to parse, place into a database if it is a new one and then notify me of only the new jobs.

I would like to do this from Outlook 2010 so it would work like this:
1) Extract body
2)  Is it from a Job_Sender in the Access Table
3)  If so, parse Body
4)  Take Job title, company, location, date of message, and link.
5)  Store in Access table if these are new.
6)  Compose new email to me daily at a certain time (4pm)  that just lists the new items

Where do I place the code ?
How can I get to the new bodies only?
Can I get to hyperlinks within the body?

Any help would be appreciated.
0
Comment
Question by:GNOVAK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 39276722
Hi, GNOVAK.

Do you want the solution to run automatically (like an Outlook rule) or do you want to run it manually.
0
 

Author Comment

by:GNOVAK
ID: 39276731
I would prefer automatically. The parse part as new mail comes in, the creation of the new mail at a specified time....
0
 
LVL 76

Accepted Solution

by:
David Lee earned 2000 total points
ID: 39276764
Where do I place the code ?
The code will go in Outlook.  You'll place it in a code module (e.g. Module 1).

How can I get to the new bodies only?
Create a rule that's triggered by the messages you want to process.  Set the rule's action to "run a script" and select your script as the one to run.  The script itself will look something like this.  I can't be more specific without knowing more about the format of the messages and the data you want to pull from them.

Sub GNOVAK(Item As Outlook.MailItem)
    Dim strBody As String
    'Extract the message body
    strBody = Item.Body
    'Check the Access table.  The function InAccessTable, which you will need to provide, will return True if the item is in the table
    If InAccessTable() Then
        'Code to parse the body goes here
        'Code to add the parsed data to Access goes here
    End If
End Sub

Open in new window


Can I get to hyperlinks within the body?
Yes.  How you do that depends on what format the messages are in.

Composing the new message is easy enough too.  Triggering creation requires more code.  Outlook doesn't have a built in means of doing that, so we have to be creative.  The approach I generally use is to trap the ReminderFire event.  This event fires each time a reminder fires.  Using some code we can check to see if the item that triggered the reminder is a task.  If it is, then we can check the subject to see if it's the right task  If it is, then the code creates and sends the message.  Something like this.  Of course you'll need to fill in the particulars.

Dim WithEvents olkReminders As Outlook.Reminders
 
Private Sub Application_Quit()
    Set olkReminders = Nothing
End Sub

Private Sub Application_Startup()
    Set olkReminders = Application.Reminders
End Sub

Private Sub olkReminders_ReminderFire(ByVal ReminderObject As Reminder)
    Dim olkTask As Outlook.TaskItem, olkMsg As Outlook.MailItem
    If ReminderObject.Item.Class = olTask Then
        Set olkTask = ReminderObject.Item
        If olkTask.Subject = "Send Daily Message" Then
            Set olkMsg = Application.CreateItem(olMailItem)
            With olkMsg
                .Subject = "Your Subject Goes Here"
                .To = "someone@company.com"
                .Body = "Your message goes here"
                .Send
            End With
            ReminderObject.Dismiss
        End If
    End If
    Set olkTask = Nothing
    Set olkMsg = Nothing
End Sub

Open in new window

0
 

Author Comment

by:GNOVAK
ID: 39280022
Thanks so much!
That was EXCELLENT!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 39280042
You're welcome!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question