• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Save all incoming messages to the hard drive

Slipstick Systems

› Outlook › Archiving › Save all incoming messages to the hard drive

Last reviewed on February 11, 2016     63 Comments

A security update disabled the Run a script option in the rules wizard in Outlook 2010 and all newer Outlook versions. See Run-a-Script Rules Missing in Outlook for more information and the registry key to fix restore it.

There are two ways you can use a VBA macro to save all messages to a hard drive: use an ItemAdd macro to watch for new messages in your Inbox or use a Run a Script rule.

If you want to save every message, it's generally better to use the ItemAdd macro since it can handle a larger volume of messages. The Run a Script rule is great for low volume accounts or when you only need to save some messages.

If you need to save messages already downloaded, see Save selected email message as .msg file. It's essentially the same macro, but works with selected messages.

Using ItemAdd

This ItemAdd macro is a simpler version of the macro at E-Mail: Save new items immediately as files. My version saves all messages in the user's profile path, in the native Outlook .msg format.

If you need to watch a folder other than your Inbox, see Working with VBA and non-default Outlook Folders.

To use this code, paste it in the ThisOutlookSession module. To test this code sample without restarting Outlook, click in the Application_Startup procedure then click Run.


Option Explicit
Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
  Dim Ns As Outlook.NameSpace
  Set Ns = Application.GetNamespace("MAPI")
  Set Items = Ns.GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
  If TypeOf Item Is Outlook.MailItem Then
  
  Dim sPath As String
  Dim dtDate As Date
  Dim sName As String
  Dim enviro As String
 
  enviro = CStr(Environ("USERPROFILE"))
   
  sName = Item.Subject
  ReplaceCharsForFileName sName, "_"
 
  dtDate = Item.ReceivedTime
  sName = Format(dtDate, "yyyymmdd", vbUseSystemDayOfWeek, _
    vbUseSystem) & Format(dtDate, "-hhnnss", _
    vbUseSystemDayOfWeek, vbUseSystem) & "-" & sName & ".msg"
     
' use My Documents for older Windows.
    sPath = enviro & "\Documents\"
  Debug.Print sPath & sName
  Item.SaveAs sPath & sName, olMSG
  
  End If
  
End Sub


Private Sub ReplaceCharsForFileName(sName As String, _
  sChr As String _
)
  sName = Replace(sName, "/", sChr)
  sName = Replace(sName, "\", sChr)
  sName = Replace(sName, ":", sChr)
  sName = Replace(sName, "?", sChr)
  sName = Replace(sName, Chr(34), sChr)
  sName = Replace(sName, "<", sChr)
  sName = Replace(sName, ">", sChr)
  sName = Replace(sName, "|", sChr)
End Sub

Run a Script Rule

This version of the macro is a "Run a Script" macro and used in a Rule. When a message arrives meeting the conditions in the rule, the script runs and saves the message. You can create a rule containing no conditions, if you want it to use the script on all messages.

For best results, all Rule Actions need to be in the script. The rule should contain only conditions.

Public Sub SaveMsg(Item As Outlook.MailItem)
  Dim sPath As String
  Dim dtDate As Date
  Dim sName As String
  Dim enviro As String
 
  enviro = CStr(Environ("USERPROFILE"))
   
  sName = Item.Subject
  ReplaceCharsForFileName sName, "_"
 
  dtDate = Item.ReceivedTime
  sName = Format(dtDate, "yyyymmdd", vbUseSystemDayOfWeek, _
    vbUseSystem) & Format(dtDate, "-hhnnss", _
    vbUseSystemDayOfWeek, vbUseSystem) & "-" & sName & ".msg"

' use My Documents in older Windows.     
    sPath = enviro & "\Documents\"
  Debug.Print sPath & sName
  Item.SaveAs sPath & sName, olMsg
End Sub
 
Private Sub ReplaceCharsForFileName(sName As String, _
  sChr As String _
)
  sName = Replace(sName, "/", sChr)
  sName = Replace(sName, "\", sChr)
  sName = Replace(sName, ":", sChr)
  sName = Replace(sName, "?", sChr)
  sName = Replace(sName, Chr(34), sChr)
  sName = Replace(sName, "<", sChr)
  sName = Replace(sName, ">", sChr)
  sName = Replace(sName, "|", sChr)
End Sub

How to use macros

First: You will need macro security set to low during testing.

To check your macro security in Outlook 2010 or 2013, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, it’s at Tools, Macro Security.

After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.

Open the VBA Editor by pressing Alt+F11 on your keyboard.

To put the code in a module:

  1. Right click on Project1 and choose Insert > Module
  2. Copy and paste the macro into the new module.

More information as well as screenshots are at How to use the VBA Editor

Save all incoming messages to the hard drive was last modified: February 11th, 2016 by Diane Poremsky
Post Views: 82

Related Posts:

  • Save Messages as *.DOC or *.DOCX File Type
  • Save Selected Email Message as .msg File
  • Save email message as text file
  • Save Outlook Email as a PDF

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Comments

  1. Aumor says

    May 5, 2025 at 5:54 am

    LOVE IT. Thank you!

    After saving the msg file, before closing the macro, i would further like to use "Microsoft
    Print to PDF" to print the created msg file as .pdf with the same 'sname' & 'spath'.

    As i understand outlook does not have a macro recorder.
    All my efforts did not get any result

    I would greatly appreciate any guidance you would be willing to provide.

    Anticipated THANKS

    Reply
  2. Michael says

    February 10, 2022 at 5:28 pm

    Diane,
    I have added several different email addresses to Outlook. How could I modify this code to so that instead of saving messages arriving to the default inbox, it saves messages arriving to a different email address that is not the default?

    Reply
  3. ahmed says

    June 14, 2020 at 4:50 am

    thank you a lot you saved my day, can i ask for one more thing i need to move the mail item after saving to archive folder but i failed to do so if you can help that will be fantastic.

    Reply
  4. Brian says

    November 30, 2018 at 11:58 am

    I have attempted to use the ItemAdd in ThisSessionOutlook, but I keep getting an this error message:

    "Run-time Error '-2147287037 (80030003)':
    The operation failed."

    When I select to debug, it highlights this line:

    Item.SaveAs sPath & sName, olMsg

    Any ideas why I am getting this message?

    Thanks,

    Brian

    Reply
  5. vojtech says

    October 5, 2018 at 4:43 am

    Hi, Thank you for your macro. How to modify the script if I want to have the sender name in the Exported msg ?
    Date-Time-Sender-Subject.msg ?

    Thank you

    Reply
  6. Evan Garcia says

    August 7, 2018 at 1:37 pm

    Love this!! Think its almost exactly what I need! Thank you!

    However, I'm getting a bug when I run it.

    Reply
  7. Zachary says

    March 31, 2018 at 2:39 am

    I am trying to put the vba as suggested above but save the message in a newly created folder which also has the same name:
    strNewFolderName = Format(dtDate - 1, "yyyymmdd", vbUseSystemDayOfWeek, _
    vbUseSystem)

    I use Mkdir command to create a folder.

    When I specify the path with this variable where I want to save the message the script is not working:
    sPath = enviro & "\Documents\" & strNewFolderName

    Debug.Print sPath & sName
    Item.SaveAs sPath & sName, olMSG

    Can you please help why it is not saving in a folder just created?

    Thanks

    Reply
    • Diane Poremsky says

      March 31, 2018 at 9:40 pm

      Does the debug.print show the correct path? (Yo might need a & "\" at the end of sPath.

      Reply
  8. James says

    August 2, 2017 at 7:55 pm

    How do I modify the code so it limits the number of characters in the email subject? I've been successful in moving emails to a SharePoint document library but get a runtime error when the subject is too long, which I think is due to the library column's character limit.

    Reply
    • Diane Poremsky says

      August 2, 2017 at 11:24 pm

      When you create the name use sname = left(sname, 10) where 10 is the number of letters.

      Reply
      • James says

        August 3, 2017 at 6:29 pm

        Prior to posting my question, I tried this on the different instances sName occurred throughout the code, but it didn't work. I guess I just missed the line where I should have defined it. It works now. Thanks for the prompt reply.

      • Diane Poremsky says

        August 3, 2017 at 10:02 pm

        You aren't alone - a lot of people miss/forget to enter valid paths...

  9. Brady says

    July 24, 2017 at 4:25 am

    hi Diane

    I have added to the code and it works perfectly when i manually drag the email with attachment to the specified folder but the itemAdd fails to be triggered when I use a rule to move the email into the specified folder.

    Our group policy prevents us from using run a script in the rule.

    Can you please help??

    Many thanks

    Reply
    • Diane Poremsky says

      July 26, 2017 at 12:32 am

      >> Our group policy prevents us from using run a script in the rule.
      They let you use macros but not script rules? that doesn't make a lot of sense. :) If you use 2013 or 2016, it's possible run a script was disabled by an update - but gpo is probably blocking you from restoring that https://www.slipstick.com/outlook/rules/outlook-2016-run-a-script-rules/

      itemadd should definitely be triggered when messages move - and as long the itemadd doesn't use an if statement to filter the mail, it should work from the rule.

      Hmmm. is the rule a server side rule? it shouldn't matter, but i wonder if moving the message on the server is causing outlook/the macro to not deleted the added item.

      Reply
  10. Thomass says

    July 13, 2017 at 8:39 am

    Hello Diane,

    I've implemented the "Using ItemAdd"-code to save new messages on disk, and it worked quite fine since last changes recommended below.

    But now, I get runtime errors from time to time without any possibility to check why.
    When I execute the procedure manually (I've implemented a button for that) on the mails causing the errors, it works fine.

    Is there any possibility to find out what causes the runtime errors ?

    Kind regards,
    Mynz

    Reply
    • Diane Poremsky says

      July 13, 2017 at 9:59 am

      What is the error code? Any idea which message is triggering the error?

      Reply
      • Thomass says

        July 14, 2017 at 4:35 am

        Hi,

        there is no errorcode, but I can determine which message it causes.

        But as I said, when executing the same procedure on the same message manually direct after the error, it works.

        Kind Regards,
        Mynz

      • Thomass says

        July 14, 2017 at 5:33 am

        This is the "errormeassage"...

      • Diane Poremsky says

        July 14, 2017 at 11:21 pm

        Typical useless outlook error message. :) Are you using ItemAdd macro or a rule? ItemAdd watches the folder and runs when a message arrives rather than having a rule tell it when to run.

      • Thomass says

        July 17, 2017 at 4:27 am

        I'm using a rule
        With this error, the rule gets deactivated.

      • Diane Poremsky says

        July 21, 2017 at 8:22 pm

        The macro with this name: Private Sub Items_ItemAdd(ByVal Item As Object) is not designed to work with rules.

        This macro: Public Sub SaveMsg(Item As Outlook.MailItem) will work with rules.

        the contents might be the same (or very similar) but you need to have the name formatted correctly.

  11. Mynz says

    May 24, 2017 at 6:28 am

    Hello Diane,

    I've implemented the "Using ItemAdd"-code to save new messages on disk.

    But since I have several rules filtering my messages, no all are stored to disk. Those, moved by a rule, are not dected by the "Using ItemAdd"-solution.

    Is there any possibility to run the script before the rules are executed ?

    Kind regards,
    Mynz

    Reply
    • Diane Poremsky says

      May 24, 2017 at 9:57 am

      You'd need to use a rule to save them first, before the next rule runs (all saved messages would be in one folder, although you could file by email address or display name). The other option is to move them using the macro either before or after saving - this would work if everything gets moved to a folder that fits a pattern (such as their email address).

      It's possible to watch more than one folder for new items (use stub macros to watch and send everything to one main macro to save), but it's not practical if you have more than maybe 5 folders to watch.

      Reply
  12. madhuri says

    September 27, 2016 at 8:34 am

    Hi,
    I am unable to use the option run a script while editing the rule.
    going to mange rules and alerts->run a script.. when I click on the script to select the script i am getting a blank window. Please help

    Reply
    • Diane Poremsky says

      September 27, 2016 at 9:36 am

      Did you put the macro in a new module or in thisoutlooksession? it usually doesn't matter, but it should be in a module and sometimes if its in thisoutlooksession, it won't show up in the list of scripts.

      Does the first line/macro name include (Item As Outlook.MailItem) ? While the word 'item' can be anything (as long as it matches what is used to reference the item in the rest of the code), you need to use that format.
      Public Sub SaveMsg(Item As Outlook.MailItem)

      Reply
  13. Billy says

    July 13, 2016 at 9:49 am

    Diane,
    I'm trying to use "Rules" to transfer my incoming "Inbox" to sent it to my hard drive "Inbox." I've tried several times and sought the help of our techs to no avail. Any help is appreciated.

    Reply
    • Diane Poremsky says

      July 19, 2016 at 11:42 pm

      you need to use a run a script rule (the second macro on this page) - standard rules won't work. if you want to save all messages, the itemadd macro will be more efficient.

      Reply
  14. Rob says

    July 4, 2016 at 3:51 pm

    Hi Diane,

    Great script! I have the script running monitoring a subfolder within my inbox. When I drag messages in there it automatically saves, assigns a category, and moves it back to the inbox. What I would like to do is have the script also monitor a second folder (this one a subfolder of my sent mail). I can get either the inbox script working, or the sent mail script working, but I am not sure how to expand the script to monitor two locations at once. I would greatly appreciate any guidance you would be willing to provide.

    Thanks!

    Rob

    Reply
    • Diane Poremsky says

      July 4, 2016 at 11:10 pm

      The Exact same script? The quick and dirty method:
      You'll need to Add these lines:
      Top:
      Private WithEvents sItems As Outlook.Items
      In App startup:
      Set sItems = Ns.GetDefaultFolder(olFolderSentItems).Items

      Copy the itemadd macro and rename it
      Private Sub sItems_ItemAdd(ByVal Item As Object)

      Alternately you could rename the itemadd macro to 'SaveandCategorize' and share it between the two:
      Private Sub Items_ItemAdd(ByVal Item As Object)
      If TypeOf Item Is Outlook.MailItem Then
      SaveandCategorize item
      End If
      End Sub

      Private Sub sItems_ItemAdd(ByVal Item As Object)
      If TypeOf Item Is Outlook.MailItem Then
      SaveandCategorize item
      End If
      End Sub

      Private Sub SaveandCategorize (ByVal Item As Object)
      ' all the itemadd code but the if/end if
      End Sub

      Even if you are need to use a different category or a different folder, you assign the folder to a variable and pass it from the 'stub macro' so both can share the code.

      Reply
      • Inderjeet says

        August 24, 2016 at 7:12 am

        I have list of reports in a excel files. Now, I want to add the sending time of these reports when send through outlook. I am trying but no luck. please help

      • Diane Poremsky says

        September 27, 2016 at 9:46 am

        Do you want to change the name of the file after you send it (attachment name doesn't change, but file name on hard drive is changed) or at the time you send it (so the attachment name has the sent time)?

  15. Mark says

    June 2, 2016 at 4:15 pm

    Hi Diane,
    Is there a way to save to desktop/hard drive non-delivery reports? I tried the macro above and it works perfectly for email that are not NDR, however, I will also need to save those NDR on my desktop. Is this possible?
    Thanks,
    Mark

    Reply
    • Diane Poremsky says

      June 2, 2016 at 4:53 pm

      with the right coding, yes. if you don't care what is saved (meeting requests etc) you can remove the if /end if lines: If TypeOf Item Is Outlook.MailItem Then
      or if you only want reports, try if typeof item is outlook.ReportItem then
      NDRs are olReport class, so you could use if item.class = olreport then

      Reply
  16. karen says

    January 13, 2016 at 4:57 pm

    Hello Diane and thank you for posting this code! Trying to send my incoming emails to a shared drive G:SharedOpen
    I am getting an error I am unable to resolve:
    Debug line: Item.SaveAs sPath & sName, olMSG

    I am unsure if it is having trouble saving the file to the remote drive or if the file type is not saving. Any input is greatly appreciated!

    Cheers!

    Reply
  17. Jonathan says

    June 4, 2015 at 11:51 am

    Hello Diane, just wanted to say we really appreciate all your time.

    Question:
    - Do you know how to prevent the macro from crashing when the file name is too long?
    I'm ok if the macro skips it but i dont want it to stop and having to restart outlook.

    Thank you.

    Reply
    • Diane Poremsky says

      June 4, 2015 at 11:04 pm

      try adding on error resume next to the macro. or trim the files names to the max length allowed.

      Reply
  18. Darren says

    June 3, 2015 at 6:00 am

    Diane,

    Many thanks for this script and for all of the help you have given - I am really new to VBA, just learning by copying/pasting and trial and error. The rule works wonderfully and saves the messages in the folder I wanted them to go to.

    In Windows Explorer it is possible to display other columns, such as "From", "From Address" and "Sender Name". Is it possible to populate one of these columns with the sender of the email when saving the email as a .msg file so I could then sort the .msg files by sender?

    I would be most grateful for any help you can give with this.

    Reply
    • Diane Poremsky says

      August 8, 2015 at 10:07 am

      Sorry it has taken me so long to get to this, I'm trying to get through a backlog of comments.

      Those fields are picked up from the windows mail app - so I can't promise anything, but will look into the possibility of writing to windows properties when saving.

      Reply
  19. ashley says

    June 1, 2015 at 9:29 am

    I want to save these emails to a particular folder on my server. How do I edit the script to allow that?

    Reply
    • Diane Poremsky says

      June 1, 2015 at 9:46 am

      use \\servername\folder as the path in the code.

      Reply
  20. ryan says

    May 5, 2015 at 3:42 pm

    I wanted to save the emails to my computer, rather than on outlook. Based off of your code, when I try this code, I receive a run time error on the Item.SaveAs line.

    Public Sub SaveMsg(Item As Outlook.MailItem)
    Dim sPath As String
    Dim dtDate As Date
    Dim sName As String

    sName = Item.Subject
    ReplaceCharsForFileName sName, "_"

    dtDate = Item.ReceivedTime
    sName = Format(dtDate, "mmddyyyy", vbUseSystemDayOfWeek, vbUseSystem) & Format(dtDate, "-hhmmss", vbUseSystemDayOfWeek, vbUseSystem) & "-" & sName & ".msg"

    sPath = "C:\IT Documents\" & Format(Date, "mmddyyyy") & "\"

    Debug.Print sPath & sName
    Item.SaveAs sPath & sName, olMSG

    End Sub

    Maybe I missed something. Thank you for your help and quick responsed

    Reply
    • Diane Poremsky says

      June 1, 2015 at 9:45 am

      I'm guessing the problem is with this - does the date folder exist? If not, you need to use code to create it.
      sPath = "C:\IT Documents\" & Format(Date, "mmddyyyy") & "\"

      There is a code sample here - https://www.slipstick.com/developer/saving-messages-to-the-hard-drive-using-vba/ - update the variables to match your code.
      dim fso as object
      StrSaveFolder = Left(StrFolderPath, Len(StrFolderPath) - 1) & "\"
      If Not FSO.FolderExists(StrFolderPath) Then
      FSO.CreateFolder (StrFolderPath)
      End If

      Reply
  21. ryan says

    May 4, 2015 at 9:00 am

    Hi, I am trying to create a macro that will save emails to a daily folder. Right now, I'm not sure if this is the ideal way of doing so, but I have a batch file that is run daily which will create a folder every day in the form (mm-dd-yyyy). My goal is to have all emails (including attachments) be saved to the daily folder. I came across your script and i believe that this helps pointing me in the right direction. I am unsure of how to run the script so that it scans the date of the email and save it to the folder that is created daily.

    Thank you for your help

    Reply
    • Diane Poremsky says

      May 5, 2015 at 10:59 am

      You want to save the messages to a folder in the windows file system or file them in Outlook?

      If in the windows file system, you need to set the file path using something like this:
      StrFolderPath = "C:\Email\" & Format(date,"yyyymmdd") & "\"
      If Not FSO.FolderExists(StrFolderPath) Then
      FSO.CreateFolder (StrFolderPath)
      End If
      then you can use the strfolderpath to direct the messages.

      Reply
  22. Mark says

    April 27, 2015 at 1:53 pm

    Diane, Thank you so much for sharing this with us. I would be interested in removing all of the email formatting, keeping the email body as text only. I can save it this way manually, is there a way to do it in this script?

    Thanks again.

    Reply
    • Diane Poremsky says

      April 28, 2015 at 9:58 pm

      Try the macro here - https://www.slipstick.com/developer/code-samples/save-email-message-text-file/

      Reply
  23. Brian says

    February 6, 2015 at 2:39 pm

    Hello Diane,
    Thanks for the great website! I'd like to make a modification to your code that will delete the message from the Outlook Inbox - only after it is saved to the hard drive successfully. Would there be an easy way to do that after the End If statement?
    Thank you,
    Brian

    Reply
    • Diane Poremsky says

      February 6, 2015 at 5:12 pm

      Try adding item.delete after the End if

      Reply
  24. Sumit j says

    February 3, 2015 at 10:20 pm

    Hi, I want to save particular mails not all, what changes needs to be done here?

    Reply
    • Diane Poremsky says

      February 4, 2015 at 12:00 am

      As they arrive or do you want to select the messages and run the macro? To do it as the messages arrive, you need to set up a rule and change the macro - this first line: Private Sub Items_ItemAdd(ByVal Item As Object) needs be changed to
      Public Sub SaveMessages(Item As MailItem). You don't need the application_start macro.

      Reply
  25. James Shanks says

    July 31, 2014 at 3:22 pm

    I am trying to use this code with a rule in outlook. I am trying to save email from a specific person and have it sent to P:\example. Where do I place this in the code???

    Reply
    • Diane Poremsky says

      August 1, 2014 at 12:53 am

      Replace this: sPath = enviro & "\Documents\"
      with sPath = "P:\Example\"

      The person will be the condition in the rule.

      Reply
  26. santhosh says

    November 19, 2013 at 11:46 pm

    Hi,
    I believe the problem is in ItemAdd.When I use the below code to monitor only one Inbox it works fine.All the new incoming mails are saved in the shared drive.
    Set Items = ns.Folders("Mailbox - ABC").Folders("Inbox").Items
    When we need to monitor two different Group Mailboxes we create a Item2 in application startup and point item2 to a Group Mailbox.However the ItemAdd doesn't pickup the mails from Items2.Please advise how to create a ItemAdd for the Item2.

    Reply
  27. santhosh says

    November 19, 2013 at 4:11 am

    Hi,
    I made the below changes in the code.
    1) Added WithEvents for Items2 below Option Explicit
    Option Explicit
    Private WithEvents Items2 As Outlook.Items
    2)Added the folder for Items2 in Private Sub Application_Startup()
    Set Items2 = ns.Folders("Mailbox - ABC").Folders("Inbox").Items
    3)Copied the itemadd macro and renamed it.
    Private Sub Items_ItemAdd2(ByVal Items As Object)

    But it didn't work.Please help

    Reply
    • Diane Poremsky says

      November 19, 2013 at 5:37 am

      Oh, sorry about that. You need to use thegetfolderpath function instead.

      Reply
  28. Santhosh says

    November 13, 2013 at 1:48 am

    Hi,
    How can we use the Itemadd code to save the incoming mails for two different Groupmailboxes?

    Reply
    • Diane Poremsky says

      November 17, 2013 at 8:24 am

      In application startup macro, you need to set items2 and point to the other folder you are watching. Copy the itemadd macro, using items2. Withevents needs copied too.

      Reply
  29. santhosh says

    November 10, 2013 at 1:09 am

    Hi,
    Thank you very much.It worked when I used ThisOutlookSession.I have a question, how to automatically save the new mails when the outlook is closed.

    Reply
    • Diane Poremsky says

      November 10, 2013 at 3:43 pm

      Sorry, outlook needs to be running for the macro to work.

      Reply
  30. santhosh says

    November 9, 2013 at 7:11 pm

    Hi,
    I opened the VBA editor and right clicked the project1 and inserted module and pasted the code.

    Reply
    • Diane Poremsky says

      November 9, 2013 at 7:26 pm

      Yeah, for the first sample, you need to use ThisOutlookSession. Application Start macros need to be there.

      Reply
  31. santhosh says

    November 8, 2013 at 4:10 am

    Hi,
    Thanks for sharing the code.While using the Itemadd code the below line item is higlighted in red.Please advise.
    Private WithEvents Items As Outlook.Items

    Reply
    • Diane Poremsky says

      November 8, 2013 at 11:35 am

      Where did you put the code? Private WithEvents Items As Outlook.Items needs to be at the top of the ThisOutlookSession module.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 31 Issue 5

Subscribe to Exchange Messaging Outlook






Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Jetpack plugin with Stats module needs to be enabled.
  • Sync Issues and Errors with Gmail and Yahoo accounts
  • Error Opening iCloud Appointments in Classic Outlook
  • Opt out of Microsoft 365 Companion Apps
  • Mail Templates in Outlook for Windows (and Web)
  • Urban legend: Microsoft Deletes Old Outlook.com Messages
  • Buttons in the New Message Notifications
  • Move Deleted Items to Another Folder Automatically
  • Open Outlook Templates using PowerShell
  • Count and List Folders in Classic Outlook
  • Google Workspace and Outlook with POP Mail
Ajax spinner

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in classic Outlook (Windows).

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Sync Issues and Errors with Gmail and Yahoo accounts

Error Opening iCloud Appointments in Classic Outlook

Opt out of Microsoft 365 Companion Apps

Mail Templates in Outlook for Windows (and Web)

Urban legend: Microsoft Deletes Old Outlook.com Messages

Buttons in the New Message Notifications

Move Deleted Items to Another Folder Automatically

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Google Workspace and Outlook with POP Mail

Newest Code Samples

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

VBA Basics

How to use the VBA Editor

Work with open item or selected item

Working with All Items in a Folder or Selected Items

VBA and non-default Outlook Folders

Backup and save your Outlook VBA macros

Get text using Left, Right, Mid, Len, InStr

Using Arrays in Outlook macros

Use RegEx to extract message text

Paste clipboard contents

Windows Folder Picker

Custom Forms

Designing Microsoft Outlook Forms

Set a custom form as default

Developer Resources

Developer Resources

Developer Tools

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2026 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.