PDA

View Full Version : Images being removed when transfering email body to new email



jstevens124
08-21-2013, 06:21 PM
When sending an email I have code running that attempts to create an exact replica of the email in a New Mail item. The problem I'm running into is that any images in the body of the email are being removed. I included an example of what happens to the picture in this new mail item.


Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.Importance = item.Importance
.SentOnBehalfOfName = strFromName
.To = strToRecip
.CC = strCCRecip
.BCC = strBCCRecip
.Subject = item.Subject & " [" & lngUID & "]"
.HTMLBody = "<HTML><BODY>" & item.HTMLBody & "</BODY></HTML>"
.Recipients.ResolveAll
.Save
.Close
End With

skatonni
08-22-2013, 05:36 PM
This code retains images

http://social.msdn.microsoft.com/Forums/vstudio/en-US/a0040962-dd3b-497d-b9ee-6266e46000de/outlook-2007-how-to-copy-the-body-of-an-emailitem-to-another-item-without-loosing-the-formating


Sub CreateFormattedCopyFromMsg()
Dim msgOrig As Outlook.mailItem
Dim msgCopy As Outlook.mailItem

Dim origDoc As Word.Document
Dim copyDoc As Word.Document

Set msgOrig = Application.ActiveExplorer.Selection.item(1)
Set msgCopy = Application.CreateItem(olMailItem)

Set origDoc = msgOrig.GetInspector.WordEditor
Set copyDoc = msgCopy.GetInspector.WordEditor

origDoc.Select
origDoc.Windows(1).Selection.Copy
copyDoc.Windows(1).Selection.PasteAndFormat wdPasteDefault

msgCopy.Subject = "This is the copy"
msgCopy.Display

End Sub