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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook Attachments

Status
Not open for further replies.

Ablecken

Programmer
Jun 5, 2001
130
0
0
US
I have some code that will scan the inbox of my outlook for a certain phrase in the subject. What i havent been able to figure out is how to save attachments to a specific location. Below is my current code. I need it to read a specific line off the subject and to read the body. Both of those I have working. If you feel that I have done something wrong please feel free to let me know.

Code:
Private Sub Form_Load()
    Dim objInboxFolders As Object, strFolder As String
    
    
    Set MyOutlook = New Outlook.Application
    With MyOutlook.GetNamespace("MAPI")
        For f = 1 To .GetDefaultFolder(olFolderInbox).Folders.Count
            If .GetDefaultFolder(olFolderInbox).Folders.Item(f).Name = "Diagnostic" Then
                strFolder = .GetDefaultFolder(olFolderInbox).Folders.Item(f).EntryID
                'MsgBox strFolder
                Exit For
            End If
        Next f
    End With
End Sub

Private Sub tmrScan_Timer()
    Dim objMessage As Object
    For Each objMessage In .GetDefaultFolder(olFolderInbox).Items
        'MsgBox objMessage.Body
        If Left(objMessage, 12) = "[Diagnostic]" Then
            objMessage.MoveTo strFolder
        End If
    Next
End Sub
 
Could you share your success, so that I may learn. Thank you.

The hardest questions always have the easiest answers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top