Hello Forum,
I´ve taken the code down below from another sheet on which this code is working.
Now the Makro " BeginnMail " gives me a compile Error as written in the Title.
Can somebody help me?
Furthermore I´d like to put the subject of the mnail together from 2 cells and a fix text.
Option Explicit
Sub Outlookliste()
' Demo fuer Outlook-Steuerung
' Geht Projektliste durch und erzeugt E-Mails
Dim objEckzelle As Range
Dim i As Long
Dim lngZeilen As Long
Dim datVergleichsdatum As Date
Dim objOutlook As Outlook.Application
On Error GoTo Fehler
Set objEckzelle = Worksheets("Daten").Range("A1")
' Zeilenzahl auslesen
lngZeilen = objEckzelle.CurrentRegion.Rows.Count
datVergleichsdatum = Date + 1
Set objOutlook = CreateObject("Outlook.Application")
' Schleife ueber Zeilen der Liste
With objEckzelle
For i = 2 To lngZeilen
'If UCase(.Cells(i, 4)) <> "X" Then
If .Cells(i, 14).Value = datVergleichsdatum Then
' Call MsgBox(.Cells(i, 1) & ": Beginnmail")
Call BeginnMail(objOutlook:=objOutlook, _
strBetreff:=.Cells(i, 1), _
strAdresse:=.Cells(i, 28), _
strMailtext:=.Cells(i, 2))
End If
' If .Cells(i, 8).Value = datVergleichsdatum Then
' Call MsgBox(.Cells(i, 1) & ": Endemail")
' Call BeginnMail(objOutlook, .Cells(i, 1), .Cells(i, 28), .Cells(i, 2))
' End If
'End If
Next
End With
Ende:
Set objOutlook = Nothing
Exit Sub
Fehler:
Call MsgBox(Err.Number & vbNewLine & Err.Description)
Resume Ende
Resume
End Sub
Private Sub BeginnMail( _
ByRef objOutlook As Outlook.Application, _
ByVal strBetreff As String, _
ByVal strAdresse As String, _
ByVal strMailtext As String)
Dim objMail As Outlook.MailItem
Set objMail = objOutlook.CreateItem(olMailItem)
With objMail
.To = strAdresse
.Body = strMailtext
.Subject = strBetreff
.Display
End With
End Sub
Bookmarks