Hi
Using VBA I'm trying to rename the attachment in the email that we received in outlook - Could you please help me guys.
Thanks
Thiru
This what I have tried so far!!!
Public Sub FolderPick()
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Dim aItem As Object
Dim emailcount As Integer
Dim emailcounter As Integer
Dim attach As Outlook.attachment
Set objNS = Application.GetNamespace("MAPI")
Set objFolder = objNS.PickFolder
If TypeName(objFolder) <> "Nothing" Then
Debug.Print vbCr & " objFolder: " & objFolder
Else
Debug.Print vbCr & "Cancel"
GoTo 20
End If
emailcount = objFolder.Items.Count
i = 1
For Each aItem In objFolder.Items
emailcounter = emailcount - i + 1
'MsgBox aItem.Subject
aItem.Subject = aItem.Subject & " " & emailcounter
For Each attach In aItem.Attachments
MsgBox attach.DisplayName
attach.DisplayName = "Hi"
Next
i = i + 1
Next
Set objFolder = Nothing
Set objNS = Nothing
MsgBox "Completed"
Exit Sub
20
MsgBox "You haven't selected any folder"
End Sub
Bookmarks