+ Reply to Thread
Results 1 to 5 of 5

Search Inbox for a word. Send to Specified Folder

  1. #1
    Registered User
    Join Date
    07-18-2014
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    14

    Search Inbox for a word. Send to Specified Folder

    Hello All,

    I'm sure this topic has been asked before, but I was receiving the below error message when using this forums search function.

    header('HTTP/1.1 503 Service Temporarily Unavailable'); header('Status: 503 Service Temporarily Unavailable'); header('Retry-After: 17200'); // in seconds print "TEST123";

    I would like to create a macro that, when executed, would search my current inbox for any emails with the keyword in either the body or subject (from sender would also be great), and move them to the specified folder. Below is the code which somewhat works. There are a few issues that need to be resolved.
    • The macro must be executed each time in order to move a single email from the inbox to the destination folder. The goal is to have this macro move all items that fit the specified criteria be moved in a single keystroke (click).
    • The macro does not move items with the keyword in the subject, only emails with the keyword in the body will get moved to the destination folder.

    If there is a better method for moving folders than using an InStr, I would be happy to use that as well. This code is far from optimal as my limited experience with VBA is from excel, not outlook. The below code has been copied from different sources to fit my needs.

    Thank you for your time


    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    08-27-2006
    Posts
    136

    Re: Search Inbox for a word. Send to Specified Folder

    Remove Exit For.

    The code for Subject appears to work fine.
    To mark "Solved" go to Thread Tools.

  3. #3
    Registered User
    Join Date
    07-18-2014
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    14

    Re: Search Inbox for a word. Send to Specified Folder

    Wow, silly I missed that.

    Ok so it seems to be working pretty well. It does move the emails all at once. Although it requires me to click twice or three times. Not sure what is hanging up the For statement. As far as the SenderEmailAddress property goes, is my syntax on this correct? Do I need an @ sign or perhaps a different property would be appropriate?

    Thank you

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    08-27-2006
    Posts
    136

    Re: Search Inbox for a word. Send to Specified Folder

    For Each works like For i = 1 to item.count. When For Each does not work, the reason is as follows.

    On a move or delete, when item one is removed from the collection, item two moves into position one but processing moves on to position two which now contains item three, skipping item two.

    One alternative is:

    Please Login or Register  to view this content.
    Try Debug.Print myTasks(i).SenderEmailAddress to see exactly what you should be looking for. There is as well myTasks(i).Sender but it should not matter.

  5. #5
    Registered User
    Join Date
    07-18-2014
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    14

    Re: Search Inbox for a word. Send to Specified Folder

    Code was perfect.

    thank you for the explanation. I appreciate that.

    Marking thread as solved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Marco to Open all contents (.xlsm) in a folder and search each file for a word
    By Mr.Post in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-11-2014, 04:08 PM
  2. Replies: 0
    Last Post: 09-12-2013, 07:43 AM
  3. Folder Names in INBOX folder
    By vjharry in forum Outlook Formatting & Functions
    Replies: 3
    Last Post: 07-12-2013, 05:25 PM
  4. Search a word file in a specific folder and copy text to excel
    By corinereyes in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-02-2012, 08:15 AM
  5. Move Inbox Subfolder Items by Category to Folder
    By ker9 in forum Outlook Programming / VBA / Macros
    Replies: 4
    Last Post: 08-30-2011, 02:03 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1