Consulting

Results 1 to 3 of 3

Thread: Re: Outlook Forwarding Script Errors Out and Stops Rule

  1. #1
    VBAX Regular
    Joined
    May 2012
    Posts
    30
    Location

    Re: Outlook Forwarding Script Errors Out and Stops Rule

    I use a rule in Outlook to run a script on every received e-mail that forwards it. It always works for a couple days, but then I get a message that says "rule encountered an error", and then I have to reactivate the rule manually.

    I'd love to figure what is causing the error, but at the very least, I'd like whatever item caused the error to just be skipped.

    Here's the code:

    Sub DoForward(Item As Outlook.MailItem)
        On Error Resume Next
        
        'Grab the item and create a forward
        Dim myFwd As Outlook.MailItem
        Set myFwd = Item.Forward
        
        'Set my e-mail as the recipient
        myFwd.Recipients.Add "email@email.com"
        
        'Set the sent e-mail to delete after sending
        myFwd.DeleteAfterSubmit = True
        
        'And send it off
        myFwd.Send
        
        'Clean-up
        Set myFwd = Nothing
    End Sub

    Any ideas would be appreciated. Thanks!

    Dan

  2. #2
    VBAX Mentor skatonni's Avatar
    Joined
    Jun 2006
    Posts
    347
    Location
    Instead of a rule you could try ItemAdd or NewMailEx.

    http://www.outlookcode.com/article.aspx?id=62
    To debug, mouse-click anywhere in the code. Press F8 repeatedly to step through the code. http://www.cpearson.com/excel/DebuggingVBA.aspx

    If your problem has been solved in your thread, mark the thread "Solved" by going to the "Thread Tools" dropdown at the top of the thread. You might also consider rating the thread by going to the "Rate Thread" dropdown.

  3. #3
    VBAX Regular
    Joined
    May 2012
    Posts
    30
    Location
    Quote Originally Posted by skatonni View Post
    Instead of a rule you could try ItemAdd or NewMailEx.

    http://www.outlookcode.com/article.aspx?id=62
    Thanks; I will try testing these alternatives.

    Any idea why my code might generate an error? I've tried looking at the mail I've received and I haven't seen a common theme. At first I assumed it was mail with large attachments or something of that sort.

Posting Permissions

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