Friday, 6 September 2019

script - outlook automated reply with unread message count


I get hundreds of daily emails and I'm looking to configure an out of office reply for outlook which will inform the recipient that I have X unread emails and that I'll get to theirs as soon as possible.


Is there a script or placeholder in a template that I can use for that effect?



Answer



All right, I took a shot at this. There are two steps - writing the script and then making a rule to execute the script.




First Part


Hit Alt + F11 to bring up VBA editor. Right click insert - module. Paste the code below in the module and to go debug - compile project


enter image description here


Private Sub myOlItems_ItemAdd(ByVal Item As Object)

End Sub

Sub AutoResponse(objmsg As Outlook.MailItem)

' define my reply message
Dim objReply As MailItem
' let's get ourselves the inbox!
Dim inbox As MAPIFolder
Set inbox = Application.GetNamespace("MAPI"). _
GetDefaultFolder(olFolderInbox)

' Let's get this reply going!
Set objReply = objmsg.Reply
' Subject Re: their subject. Standard
objReply.Subject = "Re: " & objReply.Subject
' Body - you define this, use the variable for the unread count in inbox
objReply.Body = "Your email has been received. I currently have " & inbox.UnReadItemCount & " unread emails in my inbox and I will get yours as soon as I can"

' Send this thing!
objReply.Send
' Reset
Set objReply = Nothing

End Sub



Second Part


Now we go to rules. You don't specify what outlook you're on, so I'm doing it in Outlook 2010:


1.home - rules - create rule - advanced options
2. Select your first condition. If you want to do it for all email, have something like emails sent only to me or where my name is in the to box.. or select nothing to have it apply to every message you receive
3. Hit Next and scroll down to and select run a script
4. Click the link for a script and select project1.autoresponse or whatever you've named it. Should be the only script available to you. Now hit OK
5. Now hit finish and OK


enter image description here




Notes for the First Part


You can change the objreply.body message to suit your needs, just concatenate the inxbox.unreaditemcount between your messages. Additionally, you can change the objreply.subject if you want to specify another subject like "email acknowledgement re:" or whatever.




Last Header


This works for me sending emails to myself. It might warn you that it may be local only if you're on exchange, this is okay. It's also possible that if you're email-superman that it will run behind as emails fly in like locusts, but there's not much we can do about that. Assuming you don't consistently receive more than 1 email every 10 seconds, you should be all right. However, you might want to put an if statement about if it comes from you don't respond or you'll end up in a loop.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...