Solved

MS Outlook + VBA

Posted on 2011-03-05
4
243 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
  • 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 69

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 69

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Read this checklist to learn more about the 15 things you should never include in an email signature.
In this step by step procedure, you will come to know the details of creating an Outlook meeting in 2007, 2010, 2013 & 2016.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

735 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