+ Reply to Thread
Results 1 to 2 of 2

Outlook Macro Help - filing emails

  1. #1
    Registered User
    Join Date
    06-02-2018
    Location
    US
    MS-Off Ver
    2013
    Posts
    1

    Outlook Macro Help - filing emails

    Hello all

    My Company recently upgraded us from Office 2010 (I believe) to 2013 and a macro that I had used for years in Outlook is having issues in the new Outlook 2013. The macro served a fairly basic function, when I go to send an email, it prompted me if I "really wanted to send it" with an option to continue or not continue. Then it would pull up the folder hierarchy so that I could file my response in the appropriate folder. I had this functionality in Lotus Notes back in the day and was surprised when I transitioned to Outlook that it was not there.

    The main issue that I am having with using the macro in Outlook 2013 is that previously, when the folder selection popped up, if I hit escape, the response would be filed in the Sent Items folder by default. If I do that in Outlook 2013, it crashes outlook and it has to be restarted.

    I am not a coder, so trying to "debug" the macro is leading me nowhere. Does anyone have a clue what is going wrong?

    Here is what I pulled from VBA in Outlook:

    Option Explicit
    Dim WithEvents objInspectors As Inspectors
    Dim WithEvents objMyNewMail As MailItem

    Private Sub Application_Startup()
    Set objInspectors = Application.Inspectors
    End Sub

    Private Sub Application_Quit()
    Set objInspectors = Nothing
    Set objMyNewMail = Nothing
    End Sub

    Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
    If Inspector.CurrentItem.Class <> olMail Then Exit Sub
    Set objMyNewMail = Inspector.CurrentItem
    End Sub

    Private Sub objMyNewMail_Send(Cancel As Boolean)
    If MsgBox("Are you sure you want to send this message?", vbYesNo + vbQuestion _
    , "SEND CONFIRMATION") = vbNo Then
    Cancel = True
    End If
    End Sub

    Private Sub Application_ItemSend(ByVal Item As Object, _
    Cancel As Boolean)
    Dim objNS As NameSpace
    Dim objFolder As MAPIFolder
    On Error Resume Next
    Set objNS = Application.Session
    If Item.Class = olMail Then
    Set objFolder = objNS.PickFolder
    If Not objFolder Is Nothing And _
    IsInDefaultStore(objFolder) And _
    objFolder.DefaultItemType = olMailItem Then
    Set Item.SaveSentMessageFolder = objFolder
    Else
    Set objFolder = _
    objNS.GetDefaultFolder(olFolderSentMail)
    Set Item.SaveSentMessageFolder = objFolder
    End If
    End If
    Set objFolder = Nothing
    Set objNS = Nothing
    End Sub

    Public Function IsInDefaultStore(objOL As Object) As Boolean
    Dim objApp As Outlook.Application
    Dim objNS As Outlook.NameSpace
    Dim objInbox As Outlook.MAPIFolder
    Dim blnBadObject As Boolean
    On Error Resume Next
    Set objApp = objOL.Application
    If Err = 0 Then
    Set objNS = objApp.Session
    Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
    Select Case objOL.Class
    Case olFolder
    If objOL.StoreID = objInbox.StoreID Then
    IsInDefaultStore = True
    Else
    IsInDefaultStore = False
    End If
    Case olAppointment, olContact, olDistributionList, _
    olJournal, olMail, olNote, olPost, olTask
    If objOL.Parent.StoreID = objInbox.StoreID Then
    IsInDefaultStore = True
    Else
    IsInDefaultStore = False
    End If
    Case Else
    blnBadObject = True
    End Select
    Else
    blnBadObject = True
    End If
    If blnBadObject Then
    MsgBox "This function isn't designed to work " & _
    "with " & TypeName(objOL) & _
    " objects and will return False.", _
    , "IsInDefaultStore"
    IsInDefaultStore = False
    End If
    Set objApp = Nothing
    Set objNS = Nothing
    Set objInbox = Nothing
    End Function

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Outlook Macro Help - filing emails

    You can edit your original post to add code tags to the code
    -
    -
    AA CodeTags.jpg

+ 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. Macro to search Outlook for emails
    By morayman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-09-2015, 05:01 AM
  2. Excel macro that will send emails from outlook
    By terreese in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-13-2014, 11:57 AM
  3. Outlook Macro to send recurring emails
    By Shanthuday in forum Outlook Formatting & Functions
    Replies: 0
    Last Post: 04-10-2013, 01:46 AM
  4. Outlook Macro to Save Emails to Specified Location
    By opattison in forum Outlook Formatting & Functions
    Replies: 1
    Last Post: 11-29-2012, 05:55 AM
  5. Macro to re-send emails using Outlook
    By zainnofear1987 in forum Outlook Programming / VBA / Macros
    Replies: 1
    Last Post: 06-13-2012, 12:24 PM
  6. Send outlook emails with message in cells to individual emails associated with them
    By abinayan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-21-2011, 06:11 AM
  7. Macro to count emails in outlook
    By vijanand1279 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-16-2011, 04:53 AM

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