PDA

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



tbonfig
06-14-2021, 05:44 PM
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/email/choosing-the-folder-to-save-a-sent-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!

gmayor
06-14-2021, 10:41 PM
Assuming the code is still present, the probable issue is attributable to Microsoft's security measures. See
https://www.gmayor.com/create_and_employ_a_digital_cert.htm (http://www.gmayor.com/create_and_employ_a_digital_cert.htm)

tbonfig
06-15-2021, 06:22 AM
Thanks Graham - I followed all the steps but I'm confused on the last part - how do I sign my macro with the certificate?

tbonfig
06-15-2021, 06:27 AM
Disregard - found out how to do it. This worked! Incredible - thanks Graham!!!

Gasman
06-21-2021, 05:32 AM
Disregard - found out how to do it. This worked! Incredible - thanks Graham!!!
Care to share?, for the benefit of others?

tbonfig
06-21-2021, 09:59 AM
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

tbonfig
07-07-2021, 09:06 AM
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!!!!!

gmayor
07-07-2021, 08:54 PM
It sounds like the certification has been lost -
https://www.gmayor.com/create_and_employ_a_digital_cert.htm (http://www.gmayor.com/create_and_employ_a_digital_cert.htm)