+ Reply to Thread
Results 1 to 16 of 16

Save outlook attachments to different folder paths based on Domain Names

  1. #1
    Forum Contributor
    Join Date
    12-12-2017
    Location
    india
    MS-Off Ver
    Google sheets
    Posts
    209

    Save outlook attachments to different folder paths based on Domain Names

    Hi All,
    Rules & Alerts not works in shared mailbox, i found a script from internet, which works perfectly in shared mailbox as per my requirements,

    but here i need a small changes to be made on that script as follows,

    if i receive email from domain name personname@abc.com then attachment should get saved to path 1 (C:\users\Input\abc\)
    if i receive email from domain name personname@efg.com then attachment should get saved to path 2 (C:\users\Input\efg\)
    if i receive email from domain name personname@xyz.com then attachment should get saved to path 3 (C:\users\Input\xyz\)

    Could someone please help me on it...

    Please Login or Register  to view this content.
    Last edited by amb2301; 08-09-2021 at 07:55 PM.

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,539

    Re: Save outlook attachments to different folder paths based on Domain Names

    Should the macro copy attachments only for those three aforementioned domains? What if an email comes from the *@aaaaa.com domain?

    Artik

  3. #3
    Forum Contributor
    Join Date
    12-12-2017
    Location
    india
    MS-Off Ver
    Google sheets
    Posts
    209
    Quote Originally Posted by Artik View Post
    Should the macro copy attachments only for those three aforementioned domains? What if an email comes from the *@aaaaa.com domain?

    Artik
    Sir,
    Thanks for looking on this thread,
    If email received from other than these 3 domains, it can be ignored.

  4. #4
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,539

    Re: Save outlook attachments to different folder paths based on Domain Names

    Please Login or Register  to view this content.
    Artik

  5. #5
    Forum Contributor
    Join Date
    12-12-2017
    Location
    india
    MS-Off Ver
    Google sheets
    Posts
    209

    Re: Save outlook attachments to different folder paths based on Domain Names

    Quote Originally Posted by Artik View Post
    Please Login or Register  to view this content.
    Artik

    Thank you so much for the code Sir, now code its reading the domain names
    but it reads only one email & rest of the unread emails are not getting processed.

    some of the lines got removed between here...

    could you please have look on it sir
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    12-12-2017
    Location
    india
    MS-Off Ver
    Google sheets
    Posts
    209

    Re: Save outlook attachments to different folder paths based on Domain Names

    also earlier script will save only "xlsb" format files, but now its saving all type of attachments inside path ..
    Last edited by amb2301; 08-09-2021 at 10:14 PM.

  7. #7
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,539

    Re: Save outlook attachments to different folder paths based on Domain Names

    Quote Originally Posted by amb2301 View Post
    now code its reading the domain names
    but it reads only one email & rest of the unread emails are not getting processed.
    Code analysis shows that it should process all messages, but only cares about unread messages. In unread it checks if they contain attachments. If they do, the attachments are copied to the appropriate folders on the disk and the message is moved to the "Processed" folder in Outlook. Unread messages that do not contain attachments remain in the "personal folder".

    Quote Originally Posted by amb2301 View Post
    some of the lines got removed between here...
    In the code you are presenting, this line
    Please Login or Register  to view this content.
    does nothing (dirName is not used later), so I removed it. If we are only interested in *.xlsb attachments, then the fragment of my code should be changed to the following
    Please Login or Register  to view this content.
    However, if unread messages (regardless of their content) were to be moved to the "Processed" folder, change the fragment like this:
    Please Login or Register  to view this content.
    Artik

  8. #8
    Forum Contributor
    Join Date
    12-12-2017
    Location
    india
    MS-Off Ver
    Google sheets
    Posts
    209

    Re: Save outlook attachments to different folder paths based on Domain Names

    Thanks Sir, I came outside for breakfast....will check & update you in an hour

  9. #9
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,539

    Re: Save outlook attachments to different folder paths based on Domain Names

    And I'll finally go to sleep.

    Artik

  10. #10
    Forum Contributor
    Join Date
    12-12-2017
    Location
    india
    MS-Off Ver
    Google sheets
    Posts
    209

    Re: Save outlook attachments to different folder paths based on Domain Names

    Sir,
    as per your updated code, i tried in my outlook, it moves all the unread emails to Processed folder, but none of the attachments getting saved in local drives..
    could you please have a look on it Sir,

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    12-12-2017
    Location
    india
    MS-Off Ver
    Google sheets
    Posts
    209

    Re: Save outlook attachments to different folder paths based on Domain Names

    Sir,
    i tried running the code in f8 mode, i found that its skipping these lines
    Please Login or Register  to view this content.
    i added this line to the code
    dirpath = "C:\users\Input\"
    Last edited by amb2301; 08-10-2021 at 05:09 AM.

  12. #12
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Save outlook attachments to different folder paths based on Domain Names

    The Result of line may be false.
    If CheckDomain(mi.SenderEmailAddress, dirpath) Then
    This link may help.

    https://contactform7.com/configurati...n-site-domain/
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  13. #13
    Forum Contributor
    Join Date
    12-12-2017
    Location
    india
    MS-Off Ver
    Google sheets
    Posts
    209

    Re: Save outlook attachments to different folder paths based on Domain Names

    Sir, Thanks for looking on this Thread,
    i made few changes, so its working & attachments are getting saved in respective paths,
    but a new problem here is ....its moving Read emails also to the processed folder, it should not happen,
    sir, could you please check & tell me ....where i made mistake ...
    Note: its working based on the email attachments

    Please Login or Register  to view this content.
    Last edited by amb2301; 08-10-2021 at 09:54 AM.

  14. #14
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Save outlook attachments to different folder paths based on Domain Names

    Try this
    Change this
    Please Login or Register  to view this content.
    as
    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    12-12-2017
    Location
    india
    MS-Off Ver
    Google sheets
    Posts
    209

    Re: Save outlook attachments to different folder paths based on Domain Names

    Thank you so much for the code sir , it worked perfectly

  16. #16
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Save outlook attachments to different folder paths based on Domain Names

    Ok. Thanks for feed back.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Monitor Outlook sub folder and save attachments to file
    By Gazmoz147 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-19-2021, 09:48 AM
  2. Save attachments in folder based on date of email.
    By Jim15 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2019, 09:51 AM
  3. Outlook Macro to save attachments to system folder with Date at end
    By WNErika in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 06-27-2017, 01:36 PM
  4. Replies: 0
    Last Post: 05-19-2017, 05:23 AM
  5. Save Outlook attachments to a folder.
    By Declamatory in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-23-2015, 06:05 AM
  6. Wants to mail on different ID attachments from a folder through Outlook
    By Nisha Dhawan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-30-2015, 09:51 AM
  7. Replies: 1
    Last Post: 10-18-2014, 05:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1