Solved

MS Outlook + VBA

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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

If you don't know how to downgrade, my instructions below should be helpful.
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
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…

762 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

20 Experts available now in Live!

Get 1:1 Help Now