Solved

MS Outlook + VBA

Posted on 2011-03-05
4
245 Views
Last Modified: 2012-06-21
I would like to check emails when they come in to outlook, then check the title of the email, if it matches what i am looking for it saves the attachment to a certain location, and then once attachment is saved starts another program - is this possible, if so how?
0
Comment
Question by:dkilby
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 35044102
I would like to check emails when they come in to outlook, then check the title of the email, if it matches what i am looking for it saves the attachment to a certain location

Yes using VBA

and then once attachment is saved starts another program - is this possible, if so how?

Possibly depends on the program but probably again using VBA.

The first part certainly can do so if ok I can draft that out and we can address the program startup as a bonus ... if that's ok?

Chris
0
 
LVL 70

Accepted Solution

by:
Qlemo earned 500 total points
ID: 35044185
Just to be quicker as Chris: Open your VBA Editor (Alt-F11), and insert the following in your application module (ThisOutlookSession):
Public WithEvents myOlItems As Outlook.Items

Public Sub Application_Startup()
  Set myOlItems = Outlook.Session.GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub myOlItems_ItemAdd(ByVal item As Object)
Dim ml As MailItem
Dim att As Attachment
  If TypeName(item) = "MailItem" Then
    Set ml = item
    If ml.Subject = "What I'm looking for" Then
      For Each att In ml.Attachments
        att.SaveAsFile "C:\Location\" & att.FileName
      Next
    End If
  End If
End Sub

Open in new window

This is the stub to save the attachments. Is is triggered whenever a mail is added to your default Inbox.
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 35044241
For executing an internal command, you just to insert this example line before line 16:
      Shell "C:\ExecLocation\Application.exe SomethingToProvide", vbNormalFocus

Open in new window

That application is started, and Outlook will continue with processing, not waiting for the application to be closed.

I did not test whether there are any constraints on above, but don't think so.
0
 

Author Closing Comment

by:dkilby
ID: 35085582
thanks for the help
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
When you have clients or friends from around the world, it becomes a challenge to arrange a meeting or effectively manage your time. This is where Outlook's capability to show 2 time zones in one calendar comes in handy.
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question