sathishesb
07-28-2011, 03:49 AM
Hi Guys,
I am using the below code to save all the attached files in the mail,
Sub test1()
Dim SubFolder As MAPIFolder
Dim Inbox As MAPIFolder
Dim ns As NameSpace
'Dim Inbox As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer
Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
i = 0
Set SubFolder = Inbox.Folders("reports")
If SubFolder.Items.Count = 0 Then
MsgBox "There are no messages in the Sales Reports folder.", vbInformation, "Nothing Found"
Exit Sub
End If
If SubFolder.Items.Count > 0 Then
For Each Item In SubFolder.Items
For Each Atmt In Item.Attachments
FileName = "C:\Report\" & Atmt.FileName
Atmt.SaveAsFile FileName
i = i + 1
Next Atmt
Next Item
End If
End Sub
the above code saves the file in the desired location at the same time i need to open the file as well.
please help me to open the attachment.
:help
I am using the below code to save all the attached files in the mail,
Sub test1()
Dim SubFolder As MAPIFolder
Dim Inbox As MAPIFolder
Dim ns As NameSpace
'Dim Inbox As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer
Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
i = 0
Set SubFolder = Inbox.Folders("reports")
If SubFolder.Items.Count = 0 Then
MsgBox "There are no messages in the Sales Reports folder.", vbInformation, "Nothing Found"
Exit Sub
End If
If SubFolder.Items.Count > 0 Then
For Each Item In SubFolder.Items
For Each Atmt In Item.Attachments
FileName = "C:\Report\" & Atmt.FileName
Atmt.SaveAsFile FileName
i = i + 1
Next Atmt
Next Item
End If
End Sub
the above code saves the file in the desired location at the same time i need to open the file as well.
please help me to open the attachment.
:help