Microsoft Outlook Process Incoming Mail and Store It Into Database using VBA Script




Microsoft Outlook Process Incoming Mail and Store into Database using VBA 

You can run a script for Outlook incoming email of particular format to achieve particular functionality. Automating things will makes do certain things better. The requirement was, when a mail with particular keyword in subject comes in Microsoft Outlook, then the mail content should be processed and stored it into db by running a script(VBA).

I have done it by following steps.

1. Disable security settings: Enable macro from Outlook>Options>Trust center>Enable notifications for all. Add Developer tab in Tabs in similar way.

2. Create Access database(somedb.accdb) to store mail content. Set up table and schema.

3. Alt + F11, to open VBA window for outlook. Try some script to test. Then create a subroutine for which incoming mail is a parameter(otherwise will not be able to add script in rules.) The subroutine will extract the message and store it into db as in stackoverflow code.

Upon test running u will get the error, "User-defined type not defined" because you didn't add the references/libraries.
Under Tools>References, Don't select Microsoft DAO 3.6 Object Library(for .mdb format) as I do, it will give "Name conflicts with existing module, project or object library" error. Add  Microsoft Office 12.0 Access Database Engine Object Library or later which is the correct reference one if your db is somedb.accdb. Done. Run to test whether something is getting inserted into db.

5. Now create  a rule for outlook. Manage rule>new rule>on incoming messages> select specific words in subject>Specify what keyword>Next>select run script> select script that we have done in VBA.
6. Try sending email with the format and check db.

References:
http://stackoverflow.com/questions/10083557/how-to-solve-the-name-conflict-error-occured-in-msaccess-2007-reports-vb6

https://msdn.microsoft.com/en-us/library/office/ee814736(v=office.14).aspx

http://stackoverflow.com/questions/15448338/attempt-to-connect-to-a-valid-database-from-outside-access-outlook-excel-using

2 comments:

  1. Interesting and amazing how your post is! It Is Useful and helpful for me That I like it very much, and I am looking forward to Hearing from your next..
    wordpress web design

    ReplyDelete
  2. Thanks for sharing this information. I really like your blog post very much. You have really shared a informative and interesting blog post with people..
    wordpress web design

    ReplyDelete