Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 10-07-2015, 10:08 PM
gmayor's Avatar
gmayor gmayor is offline Outlook 2010 Rule nightmare Replies Windows 7 64bit Outlook 2010 Rule nightmare Replies Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The following script should do the trick when run from your rule. Select a message and use the Test macro to test the setup, then make the changes indicated.

Code:
Option Explicit
Sub TestReply()
Dim olMsg As MailItem
    On Error Resume Next
    Set olMsg = ActiveExplorer.Selection.Item(1)
    AutoReply olMsg
lbl_Exit:
    Exit Sub
End Sub


Sub AutoReply(oItem As MailItem)
Dim olInsp As Outlook.Inspector
Dim wdDoc As Object
Dim oRng As Object
Dim olOutMail As MailItem
Dim strTemplate As String
Const strTemplatePath As String = "D:\Word 2010 Templates\" 'The path to the templates
    With oItem
        MsgBox .CC 'remove after testing
        If .CC = "Ouma.Hexi@inside.co.uk" Then 'Use the text that appears in the message box above
            Set olInsp = .GetInspector
            Set wdDoc = olInsp.WordEditor
            Set oRng = wdDoc.Range
            With oRng.Find
                Do While .Execute(FindText:="limited author")
                    strTemplate = strTemplatePath & "Template1.oft"
                    Exit Do
                Loop
                GoTo CreateMessage
            End With
            Set oRng = wdDoc.Range
            With oRng.Find
                Do While .Execute(FindText:="cannot read your email")
                    strTemplate = strTemplatePath & "Template2.oft"
                    Exit Do
                Loop
                GoTo CreateMessage
            End With
CreateMessage:
            .Display
            wdDoc.Range.Copy
            .Close 0
            Set olOutMail = CreateItemFromTemplate(strTemplate)
            With olOutMail
                .To = oItem.To
                .Subject = oItem.Subject
                Set olInsp = .GetInspector
                Set wdDoc = olInsp.WordEditor
                Set oRng = wdDoc.Range
                oRng.collapse 0
                oRng.Paste
                .Display
                '.Send 'Restore after testing
            End With
        End If
    End With
lbl_Exit:
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook 2010 Rule nightmare Replies Outlook eating my replies Cec Britton Outlook 1 08-16-2014 09:41 AM
Outlook 2010 Rule nightmare Replies Replies In Outlook Go To My Inbox abraxis Outlook 2 06-07-2014 11:51 AM
Outlook 2010 Rule nightmare Replies Outlook 2010 rule not working khughes46 Outlook 1 05-06-2014 10:09 AM
Outlook 2010 Rule nightmare Replies Outlook 2007/2010 - need a rule to approve /reject emails before actual sending senglory Outlook 1 09-12-2011 10:09 AM
Outlook 2010 rule has stopped 'seeing' Contact entries LakeGator Outlook 0 11-11-2010 07:31 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:43 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft