Hi Everybody
I wrote a small macro in my outlook macros it is working fine but i want to run that automatically when i open my outlook and once after opening it
i want to refresh my out look for every five minutes so that my macro will run for every five mins
and here is the code what i wrote
Regards
Seshu
I wrote a small macro in my outlook macros it is working fine but i want to run that automatically when i open my outlook and once after opening it
i want to refresh my out look for every five minutes so that my macro will run for every five mins
and here is the code what i wrote
Code:
Sub auto_open()
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
If Inbox.Items.Count = 0 Then
MsgBox "There are no messages in the Inbox.", vbInformation, _
"Nothing Found"
Exit Sub
End If
For Each Item In Inbox.Items
For Each Atmt In Item.Attachments
FileName = "C:\Email Attachments\" & Atmt.FileName
Atmt.SaveAsFile FileName
i = i + 1
Next Atmt
Next Item
If i > 0 Then
MsgBox "I found " & i & " attached files." _
& vbCrLf & "I have saved them into the C:\Email Attachments folder." _
& vbCrLf & vbCrLf & "Have a nice day.", vbInformation, "Finished!"
Else
MsgBox "I didn't find any attached files in your mail.", vbInformation, _
"Finished!"
End If
End Sub
Seshu
Comment