Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Looking at outlook folders in LAN Environment

Status
Not open for further replies.

philcon

Technical User
Feb 5, 2002
139
GB
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) <> &quot;\&quot; Then sPathName = sPathName & &quot;\&quot;
If Dir(sPathName, vbDirectory) = &quot;&quot; Then Exit Sub

Set oOutlook = New Outlook.Application
Set oNs = oOutlook.GetNamespace(&quot;MAPI&quot;)
Set oFldr = oNs.GetDefaultFolder(olFolderInbox)

For Each oMessage In oFldr.Items
If oMessage.Subject = &quot;DTGBBF New Brief&quot; 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top