I have a VBScript that creates a task using an incoming email in outlook. There's a rule for incoming mail that triggers the script if the email contains a certain word in the subject, and moves it to a "Processed" folder to show that it's been handled.
Occasionally the VBScript portion of this setup stops working. The outlook rule still recognizes the emails and moves them to the "Processed" folder, but the VBScript does nothing. Things that seem to break it are closing and opening outlook...but only about half the time. The one thing that breaks it reliably is logging off that account and logging back on.
The way i fix it is by removing or renaming the VbaProject.OTM file, opening the VBScript editor through outlook, and pasting in the same old code i had previously. The script will then work great until the next reboot/logoff/random disruption.
What's breaking my code!? It's driving me nuts because my company relies on this script, and it dies without warning every once in a while, keeping us all on our toes. Any ideas are welcomed...thanks.
My problem is very similar to this one: http://www.experts-exchange.com/Software/Office_Productivity/Groupware/Outlook/Q_20703945.html?sfQueryTermInfo=1+disabl+macro+outlook
But the solution that works for them, doesn't work for me (long term).
Here's a copy of my code:
Sub MakeTaskFromMail2(MyMail As Outlook.MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Dim objTask As Outlook.TaskItem
Dim preTaskSubject As String
Dim taskSubject As String
Dim taskDate As String
Dim subjLength As Integer
strID = MyMail.EntryID
Set olNS = Application.GetNamespace("
Set olMail = olNS.GetItemFromID(strID)
Set objTask = Application.CreateItem(olT
subjLength = Len(olMail.Subject)
subjLength = subjLength - 6
preTaskSubject = Right$(olMail.Subject, subjLength)
taskSubject = Right$(preTaskSubject, subjLength - 9)
taskDate = Left$(preTaskSubject, 8)
.Subject = preTaskSubject
' .StartDate = olMail.SentOn
.Body = olMail.Body
Call CopyAttachments(olMail, objTask)
Set objTask = Nothing
Set olMail = Nothing
Set olNS = Nothing