Automatically detaching an attachment to a PC Folder

K

Karen Middleton

Everyday I get a email with the same subject line and one text file
attachment.

I am new to Outlook kindly provide me a step by step procedure to
automatically export the text file attachment into the local PC
folder.

After exporting the text file to the local PC folder I want to trigger
a Windows executable.

I would appreciate if you could kindly provide me the process for
setting up this process automation in Outlook.

Can I also use Outlook Express.

Thanks
Karen
 
H

Helmut Obertanner

Hello Karen,

you could do that with a VBA script in Outlook.
This sample script checks for new arrived Emails (unread) and see if it had
PDF Files attached.
If so, the attachments are save to a Folder on Harddisk. (C:\Temp)
If you want to start an executable you can do that with a wshshell object.

Hope this get you started.

Start Outlook, Press Alt+F11
Double click Outlook Session

Paste in this code...

-------------------------- Begin of
Code -----------------------------------------

'
' By Helmut Obertanner
' DATALOG Software AG 2005
' http://www.datalog.de
' Saves PDF File from incomming Attachments to C:\Temp
'
' Install:
'
' Start Outlook
' Press 'Alt + F11'
' Double Click on Outlook Session
' Paste this code below
'
Private Sub Application_NewMail()

CheckForPDFFiles

End Sub

Private Sub CheckForPDFFiles()
Dim objItems As Outlook.Items
Dim objInbox As MAPIFolder
Dim objMail As Outlook.MailItem
Dim objAttachment As Outlook.Attachment
Dim strFileName As String
Dim strTargetPath As String

On Error Resume Next

' Get the Inbox Folder
Set objInbox = Session.GetDefaultFolder(olFolderInbox)

' Get new unread Mails from Inbox folder
Set objItems = objInbox.Items.Restrict("[MessageClass] = 'IPM.Note' AND
[Unread] = true")

For Each objMail In objItems
'Check if we have attachments

For Each objAttachment In objMail.Attachments

'Check if we have a .PDF File
strFileName = LCase(objAttachment.FileName)

If Right(strFileName, 4) = ".pdf" Then
objAttachment.SaveAsFile ("C:\Temp\" &
Format(objMail.ReceivedTime,"yymmddhhMMss") & "-" & strFileName)

End If

Next

Next
End Sub

-------------------------- End of
Code --------------------------------------------

--
with regards

Helmut Obertanner
Technical Consultant

Softwaredevelopment
DATALOG Software AG | Zschokkestr. 36 | D-80687 Munich
web: www.datalog.de


.... and IT works!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top