Link to home
Start Free TrialLog in
Avatar of Yiyi0912
Yiyi0912Flag for United States of America

asked on

Save Email Attachments using VBA Excel

Hello...I'm a complete novice in the VBA world and attempting to learn as much as possible from experts like yourselves and need all the help you can assist me with.

My objective is to extract all email attachments in a predefined email account and save them to a designated network folder.  After detaching the email attachments, I am supposed to move the emails to specified folders within the email account.  The VBA I am using was adapted from Ron Bruin.  I am using MS Office 2010 and Windows 7.

Problems I am experiencing with the code:
1.  Code stops processing even though has not finished looping thru all the emails in the email account.
2.  Some of the attachments it extracts can not be read.  When I try to open the attachment (usually an Excel file), I get the following error message:  "The file you are trying to open is in a different format than specified by the file extension.  Verify that the file is not corrupted and is from a trusted source before opening the file.  Do you want to open the file now?"  When I do, the file contains garbage.  The thing is that when I go to the actual email containing the attachment, and open the attachment from the email, the file is fine and does not prompt me with the error message indicated above.  I haven't been able to figure out why it is doing this.  

File attachments from the emails come in different formats.  Some are Word, Adobe and even Zipped folders, but most are Excel.  Any advise you can provide, is of great assistance.  Thank you!
Email-Attachment-Extraction.xlsm
ASKER CERTIFIED SOLUTION
Avatar of darbid73
darbid73
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Yiyi0912

ASKER

Thank you so very much!  I've altered the code as you recommended and it seems to be working perfectly!  Many thanks for your time.
Thank you!