Solved

MS Outlook + VBA

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

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…
Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
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 …
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

803 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