Diane Poremsky
Senior Member
- Outlook version
- Outlook 2016 32 bit
- Email Account
- Office 365 Exchange
This code works here.... not a good video but it shows the flashing that can't be avoided using word object model to copy.
ETA: this is a slightly better video - I'm closing the incoming message right after the copy. And I'm showing the sent copy.
It works with closing the incoming message after the copy, but without the display in the new message, it doesn't send the message.
ETA: this is a slightly better video - I'm closing the incoming message right after the copy. And I'm showing the sent copy.
It works with closing the incoming message after the copy, but without the display in the new message, it doesn't send the message.
Code:
Sub SendTransfer(Item As Outlook.MailItem)
Dim objMsg As MailItem
' Add reference to Word library
' in VBA Editor, Tools, References
Dim objWord As Word.Application
Dim objInsp As Inspector
Dim objDoc As Word.Document
Dim objSel As Word.Selection
On Error Resume Next
If Not Item Is Nothing Then
If Item.Class = olMail Then
Item.Display
Set objInsp = Item.GetInspector
If objInsp.EditorType = olEditorWord Then
Set objDoc = objInsp.WordEditor
Set objWord = objDoc.Application
Set objSel = objWord.Selection
With objSel
'use wholestory to copy the entire message body
.WholeStory
.Copy
End With
Item.Close olDiscard
End If
End If
End If
Set objMsg = Application.CreateItem(olMailItem)
Set objInsp = objMsg.GetInspector
Set objDoc = objInsp.WordEditor
Set objSel = objDoc.Windows(1).Selection
With objMsg
.Subject = "Transfers " & Item.Subject
.Recipients.Add "diane@contrarytech.com"
objSel.PasteAndFormat (wdFormatOriginalFormatting)
.Display
.Send
End With
End Sub
Last edited: