HI all,
I used the following code to copy file attachments from outlook on my standalone PC.
Elements of the code have been taken from a book which mentioned that Network outlook folders needed to be treated slightly differently.
Because the next step of my project is to distribute the application over a small LAN,does anyone have any ideas what the implications are, and how to resolve them.
Also, just as an aside, I originally wanted to change the e-mail subject as part of this code, so that it wouldn't be re-read each time. However I had to give up as it either affected the rest of the code, or only changed one of the e-mails in the inbox. Any ideas ?
Private Sub Command17_Click()
Dim oOutlook As Outlook.Application
Dim oNs As Outlook.NameSpace
Dim oFldr As Outlook.MAPIFolder
Dim oMessage As Object
Dim sPathName As String
Dim oAttachment As Outlook.Attachment
Dim iCtr As Integer
Dim iAttachCnt As Integer
Dim strSubject As String
On Error GoTo ErrHandler
sPathName = "c:\phil\"
If Right(sPathName, 1) <> "\" Then sPathName = sPathName & "\"
If Dir(sPathName, vbDirectory) = "" Then Exit Sub
Set oOutlook = New Outlook.Application
Set oNs = oOutlook.GetNamespace("MAPI"
Set oFldr = oNs.GetDefaultFolder(olFolderInbox)
For Each oMessage In oFldr.Items
If oMessage.Subject = "DTGBBF New Brief" Then
With oMessage.Attachments
iAttachCnt = .Count
If iAttachCnt > 0 Then
For iCtr = 1 To iAttachCnt
.Item(iCtr).SaveAsFile sPathName _
& .Item(iCtr).FileName
Next iCtr
End If
End With
End If
DoEvents
Next oMessage0
I used the following code to copy file attachments from outlook on my standalone PC.
Elements of the code have been taken from a book which mentioned that Network outlook folders needed to be treated slightly differently.
Because the next step of my project is to distribute the application over a small LAN,does anyone have any ideas what the implications are, and how to resolve them.
Also, just as an aside, I originally wanted to change the e-mail subject as part of this code, so that it wouldn't be re-read each time. However I had to give up as it either affected the rest of the code, or only changed one of the e-mails in the inbox. Any ideas ?
Private Sub Command17_Click()
Dim oOutlook As Outlook.Application
Dim oNs As Outlook.NameSpace
Dim oFldr As Outlook.MAPIFolder
Dim oMessage As Object
Dim sPathName As String
Dim oAttachment As Outlook.Attachment
Dim iCtr As Integer
Dim iAttachCnt As Integer
Dim strSubject As String
On Error GoTo ErrHandler
sPathName = "c:\phil\"
If Right(sPathName, 1) <> "\" Then sPathName = sPathName & "\"
If Dir(sPathName, vbDirectory) = "" Then Exit Sub
Set oOutlook = New Outlook.Application
Set oNs = oOutlook.GetNamespace("MAPI"
Set oFldr = oNs.GetDefaultFolder(olFolderInbox)
For Each oMessage In oFldr.Items
If oMessage.Subject = "DTGBBF New Brief" Then
With oMessage.Attachments
iAttachCnt = .Count
If iAttachCnt > 0 Then
For iCtr = 1 To iAttachCnt
.Item(iCtr).SaveAsFile sPathName _
& .Item(iCtr).FileName
Next iCtr
End If
End With
End If
DoEvents
Next oMessage0