Ich habe ein Makro, das eine Outlook-Vorlage laden soll, einen Excel-Bereich kopieren und dann als Bild in diese Vorlage einfügen.Excel-Bereich in Outlook einfügen Vorlage
In meinem Code wird das Bild jedoch über die E-Mail-Vorlage eingefügt. Daher habe ich nur das Bild, das die gesamte E-Mail überschreibt.
Wie kann ich das Bild nur zum E-Mail-Text hinzufügen, wenn sowohl die Vorlage als auch das Bild darin enthalten sind?
Hier ist mein Code:
Sub Update()
Set otlApp = CreateObject("Outlook.Application")
Set otlNewMail = otlApp.CreateItemFromTemplate("C:\Users\JohnDoe\Desktop\MyVBA\OutlookTemplate.oft")
With otlNewMail
vTemplateBody = otlNewMail.HTMLBody
vTemplateSubject = "Daily Update"
.Close 1
End With
'Creating the email from the template
Set otlApp = CreateObject("Outlook.Application")
Set otlNewMail = otlApp.CreateItem(0)
With otlNewMail
.Display
.Bcc = vToList
.Subject = vTemplateSubject
.HTMLBody = vTemplateBody
End With
'Get Outlook's Word editor
otlNewMail.Display
Dim wordDoc As Word.Document
Set wordDoc = otlNewMail.GetInspector.WordEditor
'Defining the range to be pasted
Set ws1 = wb.Worksheets("Table")
ws1.Activate
Range(ws1.Cells(1, 10), ws1.Cells(1, 15)).Copy
'To paste as picture
wordDoc.Range.PasteAndFormat wdChartPicture
End Sub