Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » Outlook Automation - Attachment Download
Closed Thread
Old 02-03-2004, 02:14 PM   #1 (permalink)
 
Newb Techie

Join Date: Feb 2004

Posts: 5

tdromgoo

Default Outlook Automation - Attachment Download

Can anyone help me modify my code so I can download attachments?

Below is the code that I am currently using.
'************************************************* *

Private Sub GetFolderInfo(fldFolder As Mapifolder)
' This procedure prints to the Immediate window information
' about items contained in a folder.
Dim objItem As Object
Dim dteCreateDate As Date
Dim strSubject As String
Dim strItemType As String
Dim strBody As String
Dim intCounter As Integer


On Error Resume Next

Debug.Print "Folder '" & fldFolder.Name & "' (Contains " & fldFolder.Items.Count & " items):"

If LCase(fldFolder.Name) = "inbox" Then
For Each objItem In fldFolder.Items
intCounter = intCounter + 1
With objItem
If LCase(.Subject) = "custom headers fix" Then
dteCreateDate = .CreationTime
strSubject = .Subject
strItemType = TypeName(objItem)

.SaveAsFile "D:\My Documents\Email Reader\test.asp"

Debug.Print vbTab & "Item #" & intCounter & " - " _
& strItemType & " - created on " _
& Format(dteCreateDate, "mmmm dd, yyyy hh:mm am/pm") _
& vbCrLf & vbTab & vbTab & "Subject: '" _
& strSubject & "'" & vbCrLf _
& strBody & vbCrLf
End If
End With
Next objItem
End If
End Sub


Private Sub Form_Load()
Dim MyNS As NameSpace
Set MyNS = Application.GetNamespace("MAPI")
Dim fldFolder As Mapifolder
Set fldFolder = MyNS.GetDefaultFolder(olFolderInbox)
Call GetFolderInfo(fldFolder)
End Sub
tdromgoo is offline  
Old 02-03-2004, 03:47 PM   #2 (permalink)
 
Banned

Join Date: May 2003

Posts: 105

imported_Jack

Default

The attachment is an item on the attachements collection. So try:

for i = 1 to objItem.Attachments.count
objItem.Attachments.item(i).SaveAsFile PathString
next

Jack
imported_Jack is offline  
Old 02-03-2004, 04:12 PM   #3 (permalink)
 
Newb Techie

Join Date: Feb 2004

Posts: 5

tdromgoo

Default

Thanks Jack,

That worked perfectly.
tdromgoo is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On