Consulting

Results 1 to 8 of 8

Thread: VBA help needed: Prompt to file email after it is sent

  1. #1
    VBAX Newbie
    Joined
    Jun 2021
    Posts
    5
    Location

    VBA help needed: Prompt to file email after it is sent

    Hi there

    Back in the land before time, I used Lotus Notes which had an awesome feature of having a prompt pop up once you sent an email, allowing you to file it away in one swift action. For reasons I can probably figure out, this is not a feature in Outlook.

    Historically, I was able to utilize some VBA code I found online. I know nothing about VBA so it was really a click and copy and paste and follow-the-instructions kind of situation for me.

    For some reason, I have not had it work for a few years as I have changed jobs a few times and used different versions of Outlook. Unfortunately, I am illiterate when it comes to this stuff so my troubleshooting amounts to nothing.

    I think this is the site/code I originally used years ago (not sure what version of Outlook I had at that time):

    https://www.slipstick.com/outlook/em...nt-message-in/

    Here is the VBA code they want you to paste into the built-in ThisOutlookSession module in Outlook:

    Private Sub Application_ItemSend(ByVal Item As Object, _
        Cancel As Boolean)
      Dim objNS As NameSpace
      Dim objFolder As MAPIFolder
      Set objNS = Application.GetNamespace("MAPI")
      Set objFolder = objNS.PickFolder
      If TypeName(objFolder) <> "Nothing" And _ 
         IsInDefaultStore(objFolder) Then
          Set Item.SaveSentMessageFolder = objFolder
      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
      On Error Resume Next
      Set objApp = CreateObject("Outlook.Application")
      Set objNS = objApp.GetNamespace("MAPI")
      Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
      Select Case objOL.Class
        Case olFolder
          If objOL.StoreID = objInbox.StoreID Then
            IsInDefaultStore = True
          End If
        Case olAppointment, olContact, olDistributionList, _
             olJournal, olMail, olNote, olPost, olTask
          If objOL.Parent.StoreID = objInbox.StoreID Then
            IsInDefaultStore = True
          End If
        Case Else
          MsgBox "This function isn't designed to work " & _
                 "with " & TypeName(objOL) & _
                 " items and will return False.", _
                 , "IsInDefaultStore"
      End Select
      Set objApp = Nothing
      Set objNS = Nothing
      Set objInbox = Nothing
    End Function
    I put this in earlier and it worked that day. Then I had to restart my computer and now it no longer works.

    I'm not sure how to troubleshoot it and hopeful someone can provide some assistance.

    Thanks so much!

  2. #2
    Assuming the code is still present, the probable issue is attributable to Microsoft's security measures. See
    https://www.gmayor.com/create_and_em...gital_cert.htm
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    VBAX Newbie
    Joined
    Jun 2021
    Posts
    5
    Location
    Thanks Graham - I followed all the steps but I'm confused on the last part - how do I sign my macro with the certificate?

  4. #4
    VBAX Newbie
    Joined
    Jun 2021
    Posts
    5
    Location
    Disregard - found out how to do it. This worked! Incredible - thanks Graham!!!

  5. #5
    VBAX Regular
    Joined
    Nov 2020
    Location
    Swansea,South Wales,UK
    Posts
    78
    Location
    Quote Originally Posted by tbonfig View Post
    Disregard - found out how to do it. This worked! Incredible - thanks Graham!!!
    Care to share?, for the benefit of others?

  6. #6
    VBAX Newbie
    Joined
    Jun 2021
    Posts
    5
    Location
    Quote Originally Posted by Gasman View Post
    Care to share?, for the benefit of others?

    Ah, of course.

    I found this website that did a great explaining it: https://www.howto-outlook.com/howto/selfcert.htm

  7. #7
    VBAX Newbie
    Joined
    Jun 2021
    Posts
    5
    Location
    Quote Originally Posted by gmayor View Post
    Assuming the code is still present, the probable issue is attributable to Microsoft's security measures. See link
    gmayor

    Since you were so incredibly helpful the first time around, I'm hoping you can help again.

    My computer restarted due to an update that was pushed on it. I didn't have a chance to properly close down any files or Outlook itself.

    I started up my computer again today, started sending emails, and noticed the save-an-email prompt is not coming up. I opened up VBA and hit the "play" or "run" button. No luck. The code is located in Module 1 if that makes a difference.

    Any idea on how to get this thing going again?

    Thanks!!!!!

  8. #8
    It sounds like the certification has been lost -
    https://www.gmayor.com/create_and_em...gital_cert.htm
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Posting Permissions

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