Consulting

Results 1 to 4 of 4

Thread: Solved: Automatic Attachment Saves and Deletes

  1. #1

    Solved: Automatic Attachment Saves and Deletes

    Hello, I have a question. I want to use an Outlook Rule to automatically save incoming Mail attachments to a disk folder. Afterwards, I want to Archive the attachment.

    Also I need to look at the SUBJECT line from the "New" incoming Mail for a key word ie;("Save This") so I know the attachment associated with this Mail Item is one I need to save.

    Problem 1: What can I use to search the subject line string to see if a particular group of letters exist

    Problem 2: How do I avoid not searching the entire inbox, only the most currently arriving piece of mail.

    Thanks in Advance

  2. #2
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    Hi and welcome to VBAX

    This kb entry should get you started - you won't need the PrintAttachment part, you'll just need to add something to archive the mailitem. It works with a mail item as it arrives, so you'll just need to get its .Subject property and test for the text you want, something like[VBA]If Instr(Item.Subject, "Save This") <> 0 Then
    ' do something
    End If[/VBA]
    K :-)

  3. #3
    Thanks very much, I'll give it a try.

  4. #4
    VBAX Regular
    Joined
    Sep 2005
    Posts
    34
    Location
    Hi guys,

    this thread started me off to solve a problem that I had been thinking about for some time and I managed to solve it fairly quickly.

    What I have is a folder full of messages and I need to check the subject to identify and then deal with particular messages. The instr solution works fine. However, looking around I have come across .find and .findnext.

    Question 1: would .find and .findnext be more efficient coding than using instr?

    To use .find and .findnext you need to use a search string and something like this would work to find any subject that starts with Jobserve UK Subscription:
    [VBA]Set myMailItem = myMail.Find("[Subject] >= ""Jobserve UK Subscription"" and [Subject] <= ""Jobserve UK Subscriptiop"" ")[/VBA]

    Question 2: How can I use wildcards with .find? I have tried using the 'like' operator as in:
    [VBA]
    Set currentAppointment = myAppointments.Find("[Subject] like ""Jac*"" ")[/VBA]
    but I get an error 'condition is not valid'.

    I forgot to ask question 3.

    When using find and findnext is there a count? I know I can use something like:


    [VBA]

    Set myAppointments = myNameSpace.GetDefaultFolder(olFolderCalendar).Items

    Set currentAppointment = myAppointments.Find("[Subject] = ""Jac"" ")

    While TypeName(currentAppointment) <> "Nothing"

    cnt = cnt + 1

    Set currentAppointment = myAppointments.FindNext

    Wend[/VBA]




    And this will tell me how many items match the search ? but there has to be a better way.


    Thanks.

    Chris
    Last edited by chrismc; 01-29-2006 at 05:38 AM. Reason: missed out third question

Posting Permissions

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