Public Sub GetAttachments()
' Declare variables
Dim ns As [NameSpace]
Dim Inbox As MAPIFolder
Dim Item As MailItem
Dim SubFolder As MAPIFolder
Dim Atmt As Attachment
Dim FileName As String
Dim olApp As Application
Dim myRecipient As Recipient
olApp = CreateObject("Outlook.Application")
ns = olApp.GetNamespace("MAPI")
' Set myRecipient =outlook ns.CreateRecipient("help")
'myRecipient.Resolve
Inbox = ns.GetDefaultFolder(OlDefaultFolders.olFolderInbox )
SubFolder = Inbox.Folders("Inbox")
' Check Inbox for messages and exit of none found
If SubFolder.Items.Count = 0 Then
Exit Sub
End If
' Check each message for attachments
For Each Item In SubFolder.Items
' Save attachments found
For Each Atmt In Item.Attachments
FileName = "h:\Email Attachments\" &
Atmt.FileName
Atmt.SaveAsFile(FileName)
End If
Next Atmt
End If
Next Item
Atmt = Nothing
Item = Nothing
ns = Nothing
End Sub
c_shah wrote:
how to save outlook email attachments using VB.net?