0

I autofoward all messages in a folder that I ran this macro on. I upgraded yesterday to 2013 and it does not work. I searched the commands used and couldn't find any of the ones I'm using not being recognized in Outlook 2013.

Sub ChangeSubjectForward(Item As Outlook.MailItem)
Item.Subject = "TAG NUMBER1234" & Item.Subject
Item.Save

Set myForward = Item.Forward
myForward.Recipients.Add "Email@email.com"

myForward.Send
End Sub
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Greg D
  • 1
  • 1
  • Maybe same problem like in?: http://stackoverflow.com/questions/30619881/microsoft-outlook-2013-error-verify-vba-project-signature/30735745#30735745 – BerndGit Jun 09 '15 at 15:04

2 Answers2

0

Your code looks good, I don't see anything strange in the code. It looks like you need to create a rule and assign the VBA macro sub to run.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • Thanks. I have it all set up and assign it to it. It runs good, no errors, but doesnt actually forward anything. I added another action to it, assigning it to a category, and it worked, so I assume the problem is on the VBA side of things http://i.imgur.com/oGkgDk9.png – Greg D Mar 13 '15 at 15:52
  • I just modified the security settings and allowed all macros and lowered all other security. When I run the rule, it still doesn't forward the messages in the folder. Appreciate anyone's assistance. – Greg D Mar 16 '15 at 12:48
0

Some Questions:

What are your rule settings that run this? Are you manually running the rule on the folder, or is the rule automatically running on a trigger? Are you getting any error messages?

Try the following:

Make sure the rule that runs your autoforward macro is lower on the rule list than the rule that files messages in that subfolder (if you're using one).

Also, since I don't know what triggers your macro, exactly, it's possible it is stopping when it is encountering a non MailItem object. Try this change:

Sub ChangeSubjectForward(olObj As Object)

dim Item As Outlook.MailItem

If olObj.Class <> olMail Then 'Making sure it is an email message
    msgbox("Object Was Not MailItem")
    Exit Sub
End If

Set Item = olObj

Item.Subject = "TAG NUMBER1234" & Item.Subject
Item.Save

Set myForward = Item.Forward
myForward.Recipients.Add "Email@email.com"

myForward.Send
End Sub

If you keep getting the message "Object Was Not MailItem" then the wrong objects are getting passed to your sub.

Trashman
  • 1,424
  • 18
  • 27