![]() |
Extract attachments from current mailobject
Hi All,
I want to create a code (macro) to extract all attachments (mostly word files) from an email object. Most of the code I see is to extract attachments from all emails in a folder. I just want to open an email, click the macro and save all the attachments in a folder of my choice at once. Does anyone have a piece of code for this? Regards Marco The Netherlands |
Extract attachments from current mailobject
On 12 Jan 2006 11:56:06 -0800, vonClausowitz wrote in
microsoft.public.outlook.program_vba: I want to create a code (macro) to extract all attachments (mostly word files) from an email object. Most of the code I see is to extract attachments from all emails in a folder. I just want to open an email, click the macro and save all the attachments in a folder of my choice at once. Does anyone have a piece of code for this? The reason you couln'd find any code for this is probably that there doesn't seem to be any benefit to coding this as a macro which can be done through a standard Menu command: File/Save Attachments/All Attachments... or in keystrokes: Alt+f na Enter Anyway, this should do what you want: Dim myItem As MailItem Dim myAtt As Attachment Const cPATH = "d:\dir\" Set myItem = Application.ActiveInspector.CurrentItem For Each myAtt In myItem.Attachments myAtt.SaveAsFile (cPATH & myAtt.FileName) Next myAtt -- Michael Bednarek http://mbednarek.com/ "POST NO BILLS" |
Extract attachments from current mailobject
Hi,
THanks for the support. i am not an expert programmer, but may i dare to ask that if there is any thing available like currentFolder instead of current Item. Because I want to save all the attachments in a folder instead of one email. Thank You Sir. "Michael Bednarek" wrote: On 12 Jan 2006 11:56:06 -0800, vonClausowitz wrote in microsoft.public.outlook.program_vba: I want to create a code (macro) to extract all attachments (mostly word files) from an email object. Most of the code I see is to extract attachments from all emails in a folder. I just want to open an email, click the macro and save all the attachments in a folder of my choice at once. Does anyone have a piece of code for this? The reason you couln'd find any code for this is probably that there doesn't seem to be any benefit to coding this as a macro which can be done through a standard Menu command: File/Save Attachments/All Attachments... or in keystrokes: Alt+f na Enter Anyway, this should do what you want: Dim myItem As MailItem Dim myAtt As Attachment Const cPATH = "d:\dir\" Set myItem = Application.ActiveInspector.CurrentItem For Each myAtt In myItem.Attachments myAtt.SaveAsFile (cPATH & myAtt.FileName) Next myAtt -- Michael Bednarek http://mbednarek.com/ "POST NO BILLS" |
Extract attachments from current mailobject
On Mon, 16 Jan 2006 21:24:03 -0800, Telecommm wrote in
microsoft.public.outlook.program_vba: THanks for the support. i am not an expert programmer, but may i dare to ask that if there is any thing available like currentFolder instead of current Item. Because I want to save all the attachments in a folder instead of one email. Thank You Sir. Now I'm confused. Isn't that exactly what you originally said you didn't want? Quote: "Most of the code I see is to extract attachments from all emails in a folder. I just want to open an email, click the macro and save all the attachments in a folder of my choice at once." "Michael Bednarek" wrote: On 12 Jan 2006 11:56:06 -0800, vonClausowitz wrote in microsoft.public.outlook.program_vba: I want to create a code (macro) to extract all attachments (mostly word files) from an email object. Most of the code I see is to extract attachments from all emails in a folder. I just want to open an email, click the macro and save all the attachments in a folder of my choice at once. Does anyone have a piece of code for this? The reason you couln'd find any code for this is probably that there doesn't seem to be any benefit to coding this as a macro which can be done through a standard Menu command: File/Save Attachments/All Attachments... or in keystrokes: Alt+f na Enter Anyway, this should do what you want: Dim myItem As MailItem Dim myAtt As Attachment Const cPATH = "d:\dir\" Set myItem = Application.ActiveInspector.CurrentItem For Each myAtt In myItem.Attachments myAtt.SaveAsFile (cPATH & myAtt.FileName) Next myAtt -- Michael Bednarek http://mbednarek.com/ "POST NO BILLS" |
Extract attachments from current mailobject
Sorry for the confusion i created.
I got your point . Thanks again. Regrads, "Michael Bednarek" wrote: On Mon, 16 Jan 2006 21:24:03 -0800, Telecommm wrote in microsoft.public.outlook.program_vba: THanks for the support. i am not an expert programmer, but may i dare to ask that if there is any thing available like currentFolder instead of current Item. Because I want to save all the attachments in a folder instead of one email. Thank You Sir. Now I'm confused. Isn't that exactly what you originally said you didn't want? Quote: "Most of the code I see is to extract attachments from all emails in a folder. I just want to open an email, click the macro and save all the attachments in a folder of my choice at once." "Michael Bednarek" wrote: On 12 Jan 2006 11:56:06 -0800, vonClausowitz wrote in microsoft.public.outlook.program_vba: I want to create a code (macro) to extract all attachments (mostly word files) from an email object. Most of the code I see is to extract attachments from all emails in a folder. I just want to open an email, click the macro and save all the attachments in a folder of my choice at once. Does anyone have a piece of code for this? The reason you couln'd find any code for this is probably that there doesn't seem to be any benefit to coding this as a macro which can be done through a standard Menu command: File/Save Attachments/All Attachments... or in keystrokes: Alt+f na Enter Anyway, this should do what you want: Dim myItem As MailItem Dim myAtt As Attachment Const cPATH = "d:\dir\" Set myItem = Application.ActiveInspector.CurrentItem For Each myAtt In myItem.Attachments myAtt.SaveAsFile (cPATH & myAtt.FileName) Next myAtt -- Michael Bednarek http://mbednarek.com/ "POST NO BILLS" |
All times are GMT +1. The time now is 02:43 PM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com