kevatarvind
Well-known Member
- Joined
- Mar 3, 2013
- Messages
- 1,047
- Office Version
- 365
- Platform
- Windows
Hi All,
i have below code which works well to reply any email from my inbox and also take body from Word file but when it paste word content to outlook body it delete original body,
Please help i want original body as it is and add new body from word
i have below code which works well to reply any email from my inbox and also take body from Word file but when it paste word content to outlook body it delete original body,
Please help i want original body as it is and add new body from word
VBA Code:
Option Explicit
Sub ReplyMail()
Dim OutApp As Outlook.Application
Dim OutMailEditor As Object
Dim WordApp As Word.Application
Dim Worddoc As Word.Document
Dim sKillWord As String
Dim sFilter As String, sSubject As String
Set OutApp = CreateObject("Outlook.Application")
Set WordApp = CreateObject("Word.Application")
sSubject = ActiveCell.Value
sFilter = "[Subject] = '" & sSubject & "'"
With OutApp.Session.GetDefaultFolder(6).Items.Restrict(sFilter).Item(1).ReplyAll
.Display
.BodyFormat = olFormatHTML
Set OutMailEditor = .GetInspector.WordEditor
' Open Word File and paste content to mail
Set Worddoc = WordApp.Documents.Open(Filename:="C:\Users\Arvind\Desktop\EMAIL TESTING MACRO\TI_BODY.docx", ReadOnly:=True)
Worddoc.Content.Copy
OutMailEditor.Range.Paste
End With
Worddoc.Close
sKillWord = "TASKKILL /F /IM Winword.exe"
Shell sKillWord, vbHide
End Sub