A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Extract attachments from current mailobject



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 12th 06, 07:56 PM posted to microsoft.public.outlook.program_vba
vonClausowitz
external usenet poster
 
Posts: 29
Default 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

Ads
  #2  
Old January 13th 06, 01:11 AM posted to microsoft.public.outlook.program_vba
Michael Bednarek
external usenet poster
 
Posts: 15
Default 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"
  #3  
Old January 17th 06, 05:24 AM posted to microsoft.public.outlook.program_vba
Telecommm
external usenet poster
 
Posts: 4
Default 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"

  #4  
Old January 18th 06, 03:40 AM posted to microsoft.public.outlook.program_vba
Michael Bednarek
external usenet poster
 
Posts: 15
Default 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"
  #5  
Old January 19th 06, 08:50 AM posted to microsoft.public.outlook.program_vba
Telecommm
external usenet poster
 
Posts: 4
Default 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"

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
The current document type cannot be sent as mail Teddy Banks Outlook Express 12 March 31st 06 02:20 AM
How do I show current date? phil07 Outlook - Calandaring 1 February 20th 06 02:21 PM
How do I extract and use the info fields from "form mail" email to Sean Outlook - Using Forms 1 January 31st 06 11:53 PM
FAST wizard, FASTconv.exe Need to extract dbx files johnh Outlook Express 1 January 24th 06 11:48 PM
Calendar defaults to current date and time Milly Staples [MVP - Outlook] Outlook - Calandaring 0 January 7th 06 08:10 PM


All times are GMT +1. The time now is 08:14 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2024 Outlook Banter.
The comments are property of their posters.