Results 1 to 7 of 7

Thread: [RESOLVED] Looking for help with an Outlook macro

  1. #1

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Resolved [RESOLVED] Looking for help with an Outlook macro

    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
    1. Look in my Inbox for an email with "Results for PokerStars Tournament" in the title
    2. Mark it as read
    3. Move it to an existing Outlook folder named "Poker Stars Wins"

    If it matters, I'm using Outlook 2002.

  2. #2
    Fanatic Member staticbob's Avatar
    Join Date
    Jan 2005
    Location
    Manchestershire, UK Cabbage: I do
    Posts
    619

    Re: Looking for help with an Outlook macro

    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
    "I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings

  3. #3

  4. #4
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Looking for help with an Outlook macro

    You don't need a macro to run a rule, just set up the rule, as per thje example below and turn it on.
    Attached Images Attached Images  
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Looking for help with an Outlook macro

    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?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Looking for help with an Outlook macro

    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.
    VB Code:
    1. Option Explicit
    2. 'Behind Outlook VBA ThisOutlookSession
    3. Private Sub MarkMovePokerEmails()
    4.  
    5.     Dim oInbox As Outlook.MAPIFolder
    6.     Dim oEmail As Outlook.MailItem
    7.     Dim oPoker As Outlook.MAPIFolder
    8.    
    9.     Dim i As Integer
    10.    
    11.     Set oInbox = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
    12.     Set oPoker = Application.GetNamespace("MAPI").Folders("Poker Stars Wins")
    13.     'loop backwards to catch any current incoming emails
    14.     For i = oInbox.Items.Count To 1
    15.         If InStr(1, oInbox.Items.Item(i).Subject, "Results for PokerStars Tournament") > 0 Then
    16.             Set oEmail = oInbox.Items.Item(i)
    17.             oEmail.UnRead = False
    18.             oEmail.Save
    19.             oEmail.Move oPoker
    20.             Set oEmail = Nothing
    21.             DoEvents
    22.         End If
    23.     Next
    24.     Set oPoker = Nothing
    25.     Set oInbox = Nothing
    26.  
    27. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Looking for help with an Outlook macro

    Quote Originally Posted by DKenny
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width