(Msg. 1) Posted: Mon Aug 25, 2008 1:06 pm
Post subject: Script to monitor emails and send info to access database Archived from groups: microsoft>public>outlook>program_vba (more info?)
Hi everyone,
I hope someone can help me with my problem. I was wondering if it's possible
to write a macro script that will monitor incoming emails and send info to an
Access database? To make it more clearer, here's the scenario: I need to
monitor emails which have the word "Handovers" on the subject line and i'd
like the macro script to put a "Yes" on one of the fields in a table within
an Access
database. Is this even possible or do i have to ask someone who's more an
expert on Access? Please, i hope someone out there can help me.
(Msg. 2) Posted: Tue Aug 26, 2008 8:16 pm
Post subject: Re: Script to monitor emails and send info to access database [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
You might use the ItemAdd event of the inbox for that. Please see the VBA
help for an example. And here's a sample for how to connect to an Access
database:
Maybe you'd just need the connection object, which supports an Execute
method. The help file should also have an example for Connection.Execute.
--
Best regards
Michael Bauer - MVP Outlook
: VBOffice Reporter for Data Analysis & Reporting
: Outlook Categories? Category Manager Is Your Tool
: <http://www.vboffice.net/product.html?pub=6&lang=en>
Am Mon, 25 Aug 2008 13:06:21 -0700 schrieb melmac:
> Hi everyone,
>
> I hope someone can help me with my problem. I was wondering if it's
possible
> to write a macro script that will monitor incoming emails and send info to
an
> Access database? To make it more clearer, here's the scenario: I need to
> monitor emails which have the word "Handovers" on the subject line and i'd
> like the macro script to put a "Yes" on one of the fields in a table
within
> an Access
> database. Is this even possible or do i have to ask someone who's more an
> expert on Access? Please, i hope someone out there can help me.
>
> Thanks,
(Msg. 3) Posted: Wed Aug 27, 2008 3:43 am
Post subject: RE: Script to monitor emails and send info to access database [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Place this script in "ThisOutlookSession" in the VB editor in Outlook (make
sure that you have macros enabled in macro security)
'##################################################
Option Explicit
' the next line sets incoming emails as an event to start
TargetFolderItems_ItemAdd
Dim WithEvents TargetFolderItems As Items
Const MBOX_NAME As String = "xxxx" ' change xxxx to match your mailbox name
'##################################################
' this routine will run each time Outllook first starts
Private Sub Application_Startup()
Dim ns As Outlook.NameSpace
Set ns = Application.GetNamespace("MAPI")
Set TargetFolderItems =
ns.Folders.Item(MBOX_NAME).Folders.Item("Inbox").Items
End Sub
'##################################################
' this is the event driven routine
Sub TargetFolderItems_ItemAdd(ByVal Item As Object)
Dim olAtt As Attachment
Dim BODY_NAME As String
Dim i As Integer
If InStr(1, Item, "Handovers") Then
Item.Display ' displays subject title in a msgbox when a mail
arrives with "Handovers" in the subject title
Put_Yes_In_Access
End If
Set olAtt = Nothing
End Sub
'##################################################
Sub Put_Yes_In_Access()
' now you need code here to put Yes in a table in an MDB
End Sub
'##################################################
' this is the Application_Quit event code in ThisOutlookSession module
Private Sub Application_Quit()
Dim ns As Outlook.NameSpace
Set TargetFolderItems = Nothing
Set ns = Nothing
End Sub
"melmac" wrote:
> Hi everyone,
>
> I hope someone can help me with my problem. I was wondering if it's possible
> to write a macro script that will monitor incoming emails and send info to an
> Access database? To make it more clearer, here's the scenario: I need to
> monitor emails which have the word "Handovers" on the subject line and i'd
> like the macro script to put a "Yes" on one of the fields in a table within
> an Access
> database. Is this even possible or do i have to ask someone who's more an
> expert on Access? Please, i hope someone out there can help me.
>
> Thanks,
>
> --
> "excel newbie"
(Msg. 4) Posted: Wed Aug 27, 2008 3:49 am
Post subject: RE: Script to monitor emails and send info to access database [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
note that some of the comment lines have over-spilled into two lines !!!!
e.g.
' the next line sets incoming emails as an event to start
TargetFolderItems_ItemAdd
All times are: Eastern Time (US & Canada) (change)
Page 1 of 1
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum