Code to download attachment from outlook emails
'Below code goes through all the unread mails from inbox folder and download the attachment
'CreateObject method to create an Outlook Application object
Set ObjO=createobject("Outlook.Application")
'GetNameSpece returns a NameSpace object of the specified type
Set olns=ObjO.GetNameSpace("MAPI")
'Get the reference of inbox folder
Set ObjFolder=olns.GetDefaultFolder(6)
'Iterate for all the unread mails and download the attchment from those mails
For each item1 in ObjFolder.Items
If item1.Unread Then
For each att in item1.attachments
FileName="D:\EmailData\" &att.FileName
att.saveasfile FileName
Next
End If
Next
hi Venkat,
ReplyDeletei really appreciate this example, but i am facing one small problem is that when i run this code it start to check the unread email from older received email
for ex.
In my outlook there are 8000 emails, it is checking unread email from Older Received date Feb 2nd,2010 email.
is ther any way to start checking unread email from recently received email i.e from todays date.
because it is increase loop iteration