save excel attachments sent by email

bonovox1

Board Regular
Joined
Aug 11, 2007
Messages
91
Hi, im trying to write a macro that will save files from a specific email address into a specific folder. I will be recieving files from 5 differnt mail addresses on a daily basis and i want to be avle to save them to a date stamped folder.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Andrew, i'm not too sure where to add in the item.sender. The below appears not to work.


For Each Item In SubFolder.Items
For Each Atmt In Item.Attachments
' Check filename of each attachment and save if it has "xls" extension
If Right(Atmt.FileName, 3) = "xls" Or Right(Atmt.FileName, 4) = "xlsx" Or Right(Atmt.FileName, 5) = "xlsx" Then
' This path must exist! Change folder name as necessary.
FileName = "C:\Email Attachments\" & _
Format(Item.CreationTime, "yyyymmdd_hhnnss_") & Atmt.FileName.Item.sender
Atmt.SaveAsFile FileName
i = i + 1
End If
Next Atmt
Next Item
 
Upvote 0
Try:

Code:
FileName = "C:\Email Attachments\" & _
Format(Item.CreationTime, "yyyymmdd_hhmmss_") & Item.Sender & Atmt.FileName
 
Upvote 0
Andrew the macro runs and exports the email attachments but does add on the email address to the file name.
 
Upvote 0
thks Andrew...i had a look at your link.....appears quite complicated for my level. Your certain that this can't be done in my macro and that the EMail address is not exposed in the Outlook object model?
 
Upvote 0
Well, we tried Sender and it doesn't exist and SenderName didn't seem to return anything. And in the link I posted Sue Mosher, an Outlook MVP, says "no obvious way to get the sender's e-mail address".
 
Upvote 0

Forum statistics

Threads
1,224,541
Messages
6,179,418
Members
452,912
Latest member
alicemil

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top