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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook Run script on newmail event relating to subject 1

Status
Not open for further replies.
Apr 27, 2006
126
GB
Hi,

I want to trigger a given action on receipt of an email with "dostuff" in the subject line.

I know its the NewMail event, but I'm just not sure how to pull the subject line into a string variable.

I'm sure it's simple but trying to search for "Outlook" and "Newmail" involved me sifting through a thousand threads about creating new e-mails..

________
clueless
 
You could use the "Rules and Alerts" tool in Outlook and perform "run a script", which is a macro.

_________________
Bob Rashkin
 
I'd rather not, plus for some reason my modules/subs arent showing in the "Run scripts"

________
clueless
 
Code:
Private Sub Application_NewMail()
   Dim ns As Outlook.NameSpace
   Dim inbox As Outlook.MAPIFolder
   Dim subject_line As String
   
   Set ns = GetNamespace("MAPI")
   Set inbox = ns.GetDefaultFolder(olFolderInbox)
   
   subject_line = inbox.Items(1).Subject
   MsgBox subject_line
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top