I have been using the following code for downloading attachments from outlook to a folder.
I now wanted to make it more specific for my purpose.
I just want to download files with .doc and pdf type to my folder.
Can some specify some way to do it
The code i hav used is as belows:
Imports Microsoft.Office.Interop Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim objOL As Outlook.Application Dim objMsg As Outlook.MailItem 'Object Dim objAttachments As Outlook.Attachments Dim objSelection As Outlook.Selection Dim I As Long Dim lngCount As Long Dim strFile As String Dim strFolderpath As String Dim strDeletedFiles As String Dim Counter As Long Dim timeStamp As DateTime = DateTime.Now strFolderpath = "C:\Documents and Settings\E1002176\My Documents\" + TextBox1.Text + "/" + TextBox2.Text If (Dir$(strFolderpath, vbDirectory) = "") Then MsgBox("'" & strFolderpath & "' not exist") MkDir(strFolderpath) MsgBox("'" & strFolderpath & "' we create it") Else MsgBox("'" & strFolderpath & "' exist") End If ' Get the path to your My Documents folder 'strFolderpath = CreateObject("WScript.Shell").SpecialFolders(16) strFolderpath = strFolderpath & "\" On Error Resume Next ' Instantiate an Outlook Application object. objOL = CreateObject("Outlook.Application") ' Get the collection of selected objects. objSelection = objOL.ActiveExplorer.Selection ' The attachment folder needs to exist ' You can change this to another folder name of your choice ' Set the Attachment folder. strFolderpath = strFolderpath ' Check each selected item for attachments. Counter = 1 For Each objMsg In objSelection objAttachments = objMsg.Attachments lngCount = objAttachments.Count If lngCount > 0 Then ' Use a count down loop for removing items ' from a collection. Otherwise, the loop counter gets ' confused and only every other item is removed. For I = lngCount To 1 Step -1 ' Get the file name. strFile = objAttachments.Item(I).FileName ' Combine with the path to the Temp folder. strFile = strFolderpath & Counter & "_" & strFile ' Save the attachment as a file. objAttachments.Item(I).SaveAsFile(strFile) Counter = Counter + 1 Next I End If Next ExitSub: objAttachments = Nothing objMsg = Nothing objSelection = Nothing objOL = Nothing MsgBox("All Selected Attachments Have Been Downloaded ...") End Sub End Class