Outlook, Recognise Email, Save Attachment, Move Email To A Subfolder

  • Hello Everyone,


    I am new to this forum, and new to Outlook VBA as well. It will be great if some one can help me out. Thanks in advance.


    My program is suppose to do following functions:


    1. Look into Inbox, go through all the emails, look for emails which has attachments.
    2. If the email has an attachment then see if it is coming from a known email id, if not then go to next email with


    attachment.
    3. If the email has attachment and matches with a given email id (defined in the function) then save the attachment as


    the senders email id.


    Part 1 to 3 is working fine
    Part 4 is where I need your help:


    4. If the email matches with a given email id then after saving the file, Move the email to a sub folder.


    This part 4 is not working properly in my program, it is moving the email twice if email has 2 attachments. Also it is


    not going to check all the emails in the Inbox. I have to reset and run the program several time to get the job done. If


    someone could help me out it will be very helpful, as I am really stuck on part 4 for a long time.


    Also to be done:
    5. This part should be able to extract only the excel file from the email attachments as that is what I need, but


    presently not able to clear step 4 so didn't got to it yet.


    Please let me know if anyone of you could help.


    Thanks a lot.
    Best Regards.


    ------------------------------------------------

  • Re: Outlook, Recognise Email, Save Attachment, Move Email To A Subfolder



    I think that will work. Not positive, though. It's untested.

  • Re: Outlook, Recognise Email, Save Attachment, Move Email To A Subfolder


    Thanks for your reply.


    This didn't worked as I need to define "sender" first before making the
    IF get_bank(sender) <> "unknown" statement.


    The loop is not working even if I define sender between For each item and If get_bank stmt, any idea how to make it work.
    Thanks a lot.[hr]*[/hr] Auto Merged Post Until 24 Hrs Passes;[dl]*[/dl]Now the code is more perfect than before but still need to be run couple of times to get all the inbox emails with attachments to move to a subfolder?
    Any idea how to fix that.
    Thanks a lot once again.
    ------------------------------------------------------------------------------


  • Re: Outlook, Recognise Email, Save Attachment, Move Email To A Subfolder


  • Re: Outlook, Recognise Email, Save Attachment, Move Email To A Subfolder


    Thanks for your reply and help.
    When I run the program it breaks at


    Atmt.SaveAsFile FileName[hr]*[/hr] Auto Merged Post Until 24 Hrs Passes;[dl]*[/dl][hr]*[/hr] Auto Merged Post Until 24 Hrs Passes;[dl]*[/dl]This get done the job by forcing the program to keep running it again and again.
    this is not the best way but get the job done.
    Any other ideas?
    Thanks a lot.



  • Re: Outlook, Recognise Email, Save Attachment, Move Email To A Subfolder


    There are no errors now, but still it is not clear why the program stops in the earlier version, why is it not going to the next item and checking all the items.
    This new version of program forces the start button over and over till there are messages.
    The job is getting done now with this program but the question remains why was it not checking all the emails when there are unread message with attachments left in the Inbox.


    So for now the problem is solved but question remains, why?
    If you are able to think about it then it's ok, else leave it.


    BTW this forum is very useful for people like me with limited knowledge of programming. Thanks.