Help!

Capture Inbound E-mail Subject with VBA

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Programming VBA RSS
Next:  buy Lynoral (Ethinyl Estradiol) online in South A..  
Author Message
Brad
External


Since: Mar 17, 2006
Posts: 154



PostPosted: Wed Sep 02, 2009 8:08 pm    Post subject: Capture Inbound E-mail Subject with VBA
Archived from groups: microsoft>public>outlook>program_vba (more info?)

I am just starting to experiment with Outlook VBA.

I am looking for a simple example of how to capture the content of an
inbound e-mail’s subject so that I can see it in VBA code.

For my first step, I would simply like to be able to do a MSGBOX to display
the captured Subject.

Thanks for your help,

Brad
Back to top
Michael Bauer [MVP - Outl
External


Since: Aug 04, 2006
Posts: 647



PostPosted: Thu Sep 03, 2009 4:10 am    Post subject: Re: Capture Inbound E-mail Subject with VBA [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

What is an 'inbound e-mail's subject'?

This prompts the subject of the first selected item in the current folder:

Dim Sel as Outlook.Selection
Set Sel=Application.ActiveExplorer.Selection
If Sel.Count>0 Then Msgbox Sel(1).Subject

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Wed, 2 Sep 2009 20:08:01 -0700 schrieb Brad:

> I am just starting to experiment with Outlook VBA.
>
> I am looking for a simple example of how to capture the content of an
> inbound e-mail's subject so that I can see it in VBA code.
>
> For my first step, I would simply like to be able to do a MSGBOX to
display
> the captured Subject.
>
> Thanks for your help,
>
> Brad
Back to top
Brad
External


Since: Mar 17, 2006
Posts: 154



PostPosted: Thu Sep 03, 2009 5:21 am    Post subject: Re: Capture Inbound E-mail Subject with VBA [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Michael,

Sorry, I didn’t explain very clearly what I am trying to do.

I have set up a little VBA module that is initiated by Outlook each time a
new e-mail arrives. It simply displays a message that control was passed to
it. This works nicely

I am now trying to capture the subject line of each e-mail and do something
with it in the VBA code.

Being new to Outlook VBA, I would like to see an example of how to get at
the subject line of each e-mail in VBA as they arrive.

Thanks for your help.

Brad




"Michael Bauer [MVP - Outlook]" wrote:

>
>
> What is an 'inbound e-mail's subject'?
>
> This prompts the subject of the first selected item in the current folder:
>
> Dim Sel as Outlook.Selection
> Set Sel=Application.ActiveExplorer.Selection
> If Sel.Count>0 Then Msgbox Sel(1).Subject
>
> --
> Best regards
> Michael Bauer - MVP Outlook
>
> : Outlook Categories? Category Manager Is Your Tool
> : VBOffice Reporter for Data Analysis & Reporting
> : <http://www.vboffice.net/product.html?pub=6&lang=en>
>
>
> Am Wed, 2 Sep 2009 20:08:01 -0700 schrieb Brad:
>
> > I am just starting to experiment with Outlook VBA.
> >
> > I am looking for a simple example of how to capture the content of an
> > inbound e-mail’s subject so that I can see it in VBA code.
> >
> > For my first step, I would simply like to be able to do a MSGBOX to
> display
> > the captured Subject.
> >
> > Thanks for your help,
> >
> > Brad
>
Back to top
Michael Bauer [MVP - Outl
External


Since: Aug 04, 2006
Posts: 647



PostPosted: Fri Sep 04, 2009 5:10 am    Post subject: Re: Capture Inbound E-mail Subject with VBA [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

For instance, see the ItemAdd event of the Inbox folder. There's an example
in the VBA help file.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Thu, 3 Sep 2009 05:21:01 -0700 schrieb Brad:

> Michael,
>
> Sorry, I didn't explain very clearly what I am trying to do.
>
> I have set up a little VBA module that is initiated by Outlook each time a
> new e-mail arrives. It simply displays a message that control was passed
to
> it. This works nicely
>
> I am now trying to capture the subject line of each e-mail and do
something
> with it in the VBA code.
>
> Being new to Outlook VBA, I would like to see an example of how to get at
> the subject line of each e-mail in VBA as they arrive.
>
> Thanks for your help.
>
> Brad
>
>
>
>
> "Michael Bauer [MVP - Outlook]" wrote:
>
>>
>>
>> What is an 'inbound e-mail's subject'?
>>
>> This prompts the subject of the first selected item in the current
folder:
>>
>> Dim Sel as Outlook.Selection
>> Set Sel=Application.ActiveExplorer.Selection
>> If Sel.Count>0 Then Msgbox Sel(1).Subject
>>
>> --
>> Best regards
>> Michael Bauer - MVP Outlook
>>
>> : Outlook Categories? Category Manager Is Your Tool
>> : VBOffice Reporter for Data Analysis & Reporting
>> : <http://www.vboffice.net/product.html?pub=6&lang=en>
>>
>>
>> Am Wed, 2 Sep 2009 20:08:01 -0700 schrieb Brad:
>>
>>> I am just starting to experiment with Outlook VBA.
>>>
>>> I am looking for a simple example of how to capture the content of an
>>> inbound e-mail's subject so that I can see it in VBA code.
>>>
>>> For my first step, I would simply like to be able to do a MSGBOX to
>> display
>>> the captured Subject.
>>>
>>> Thanks for your help,
>>>
>>> Brad
>>
Back to top
Luc
External


Since: Sep 07, 2009
Posts: 2



PostPosted: Mon Sep 07, 2009 4:10 am    Post subject: Re: Capture Inbound E-mail Subject with VBA [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Thu, 3 Sep 2009 05:21:01 -0700, Brad <Brad.RemoveThis@discussions.microsoft.com>
wrote:

> Michael,
>
> Sorry, I didn't explain very clearly what I am trying to do.
>
> I have set up a little VBA module that is initiated by Outlook each time a
> new e-mail arrives. It simply displays a message that control was passed to
> it. This works nicely
>
> I am now trying to capture the subject line of each e-mail and do something
> with it in the VBA code.


Try this:

Sub IncomingMailHandler(ThisMail as MailItem)
MsgBox ThisMail.Subject
End Sub


To "install" the script, create a new "run script" rule for incoming
messages in Tools / Rules and Alerts (if that isn't how you already did
it).
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Programming VBA 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