![]() |
#4
|
||||
|
||||
![]()
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 |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Cec Britton | Outlook | 1 | 08-16-2014 09:41 AM |
![]() |
abraxis | Outlook | 2 | 06-07-2014 11:51 AM |
![]() |
khughes46 | Outlook | 1 | 05-06-2014 10:09 AM |
![]() |
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 |