Outlook 2013 script to save email subject in an excel

Hi team

How can I create an Outlook 2013 script to run as rule in order to save in an excel file all the email subjects received.
And also, how can I add the date even?

Kind regards
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


you could try to insert a similar code in the ThisOutlookSession module of Outlook

Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
  Dim olApp As Outlook.Application
  Dim objNS As Outlook.Namespace
  Set olApp = Outlook.Application
  Set objNS = olApp.GetNamespace("MAPI")
  ' default local Inbox
  Set Items = objNS.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub Items_ItemAdd(ByVal item As Object)
  Dim xlApp As Object
  On Error GoTo ErrorHandler
  Dim Msg As Outlook.MailItem
  If TypeName(item) = "MailItem" Then
    Set Msg = item

    Set xlApp = CreateObject("Excel.Application")
    With xlApp
        .Visible = True
        .EnableEvents = True
    End With
    strFile = "c:\Documents\Book991.xlsx"  'Put your file path.
    Set destWb = xlApp.Workbooks.Open(strFile)
    Set destWs = destWb.Worksheets("Log sheet")
    destWs.Range("A" & Rows.Count).End(xlUp).Offset(1) = Msg.ReceivedTime
    destWs.Range("A" & Rows.Count).End(xlUp).Offset(0, 1) = Msg.Subject
    destWb.Close True
    Set destWs = Nothing
    Set destWb = Nothing
    Set xlApp = Nothing
  End If
Set Msg = Nothing
  Exit Sub
  MsgBox Err.Number & " - " & Err.Description
  Resume ProgramExit
End Sub

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.