Hallo zusammen,
bei folgendem Skript laufe ich auf einen Laufzeitfehler 287 und ich verstehe nicht wieso. Google war leider nicht hilfreich :/ Ich arbeite mit HTMLBody, da ich eine Signatur eingefügt haben möchte. Habe auch "htmlBody = "Test
" & .htmlBody" versucht, also ohne den Umweg über die Variable. Beide Male die selbe Fehlermeldung.
Das Skript habe ich zur Übersicht gekürzt, die Variablen sind alle als String deklariert.
Habt ihr eine Idee? Vielen Dank im Voraus!
Gruß René
Sub emailerstellen() Dim objOutlook As Object Dim objMail As Object [...] [...] file = Dir(pfad & "*.xlsx") Do While file <> "" Set objOutlook = CreateObject("Outlook.Application") Set objMail = objOutlook.CreateItem(0) With objMail .Display .GetInspector olOldBody = .htmlBody .To = an .cc = cc .Subject = "Online Survey (Corona)" .htmlBody = "Test" & olOldBody .Attachments.Add pfad & file End With file = Dir End If Loop End Sub
____________________[Cc]Sub emailerstellen() Dim objOutlook As Object Dim objMail As Object Set objOutlook = CreateObject("Outlook.Application") file = Dir(pfad & "*.xlsx") Do While file <> "" Set objMail = objOutlook.CreateItem(0) With objMail .GetInspector olOldBody = .htmlBody .To = an .cc = cc .Subject = "Online Survey (Corona)" .htmlBody = "Test" & olOldBody .Display .Attachments.Add pfad & file End With Set objMail = Nothing file = Dir ' End If Dieses End If ist zu viel Loop End Sub
____________________[Cc]Sub emailerstellen() Dim objOutlook As Object Dim objMail As Object Set objOutlook = CreateObject("Outlook.Application") Set objMail = objOutlook.CreateItem(0) With objMail .GetInspector olOldBody = .htmlBody .To = an .cc = cc .Subject = "Online Survey (Corona)" .htmlBody = "Test" & olOldBody .Display file = Dir(pfad & "*.xlsx") Do While file <> "" .Attachments.Add pfad & file file = Dir Loop End With Set objMail = Nothing End Sub
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | Sub emailerstellen() Dim objOutlook As Object Dim objMail As Object Dim olOldBody As String Dim Pfad As String Set objOutlook = CreateObject("Outlook.Application") file = Dir(sPfad & "*.xlsx") Do While file <> "" Set objMail = objOutlook.CreateItem(0) With objMail .bodyformat = 2 .GetInspector.Display olOldBody = .htmlBody .To = an .cc = cc .Subject = "Online Survey (Corona)" .htmlBody = "Test" & olOldBody .Attachments.Add Pfad & file End With Set objMail = Nothing file = Dir Loop End Sub |