Solved

MS Outlook + VBA

Posted on 2011-03-05
4
239 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 68

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 68

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now