PDA

Click to See Complete Forum and Search --> : [RESOLVED] Looking for help with an Outlook macro


MartinLiss
Jun 8th, 2006, 06:34 PM
Well actually I'm looking for someone to write it for me and explain how to implement it.

What I'd like it to do when I press Ctrl-P is

Look in my Inbox for an email with "Results for PokerStars Tournament" in the title
Mark it as read
Move it to an existing Outlook folder named "Poker Stars Wins"

If it matters, I'm using Outlook 2002.

staticbob
Jun 9th, 2006, 08:03 AM
Martin,

Why don't you use the built in Rules Wizard to do all of this for you, you then just need a macro to run the rule ?

Bob

MartinLiss
Jun 16th, 2006, 10:59 AM
OK, that's a good idea but unfortunately I have no experience in actually writing Outlook macros so I still would appreciate help with that.

DKenny
Jun 16th, 2006, 11:05 AM
You don't need a macro to run a rule, just set up the rule, as per thje example below and turn it on.

RobDog888
Jun 16th, 2006, 11:06 AM
Martin, doesn the destination folder reside at the top level folder or is it a subfolder under the Inbox or such?

Almost done...

Edit: but the rule wont run by Ctl+P unless Martin wants to change it to automatic?

RobDog888
Jun 16th, 2006, 11:12 AM
Ok,assuming that the destination folder is at the same folder level as the Inbox... just add RegisterHotkey API code to invoke the procedure behind Outlook VBA (Press Alt+F11). If you dont want the hotkey then I can add code to add a menu item in Outlook or a toolbar button. Let me know. ;)
Option Explicit
'Behind Outlook VBA ThisOutlookSession
Private Sub MarkMovePokerEmails()

Dim oInbox As Outlook.MAPIFolder
Dim oEmail As Outlook.MailItem
Dim oPoker As Outlook.MAPIFolder

Dim i As Integer

Set oInbox = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
Set oPoker = Application.GetNamespace("MAPI").Folders("Poker Stars Wins")
'loop backwards to catch any current incoming emails
For i = oInbox.Items.Count To 1
If InStr(1, oInbox.Items.Item(i).Subject, "Results for PokerStars Tournament") > 0 Then
Set oEmail = oInbox.Items.Item(i)
oEmail.UnRead = False
oEmail.Save
oEmail.Move oPoker
Set oEmail = Nothing
DoEvents
End If
Next
Set oPoker = Nothing
Set oInbox = Nothing

End Sub

MartinLiss
Jun 16th, 2006, 02:27 PM
You don't need a macro to run a rule, just set up the rule, as per thje example below and turn it on.Thanks. I've created it and as soon as I get a chance to play some poker I'll see if it works :) but I'm sure it will.