Hallo Liebes Forum,
ich möchte das beim Öffnen der Db automatische Email gesendet wird. Dazu habe ich ein Makro Autoexec mit einer Funktion erstellt nur leider funktioniert dieser nicht beim Starten der Datenbank es zeigt mir auch keinen Fehler im Code an..
Kann mir da jemand weiterhelfen?
Lg
Hallo,
funktioniert das Makro, wenn du es nach dem Öffnen der DB manuell startest?
Ansonsten zeig mal das Makro.
Hallo, nein es funktioniert dann auch nicht.
Hallo,
wie Wäre es, auch den Code der Funktion zu posten?
Steht in allen (!) Modulköpfen "Option Explicit"? Falls nicht, dies nachholen und den Code kompilieren.
Hallo, mein Modul-Code
Option Compare Database
Option Explicit
Public Function ()
Dim db As DAO.Database, rs AS DAO.Recordset
Dim myMail As Outlook.MailItem, myOutlApp As Outlook.Application
Set db = CurrentDB()
Set rs = db.OpenRecordset
If Not rs.EOF And Not rs.BOF Then
rs.MoveFirst
Do While Not rs.EOF
Set myOutlApp=New Outlook.Application
Set myMail=myOutlApp.CreateItem(olMailItem)
With myMail
.To=
.Subject=
.Body=
.Send
End With
Set myMail=Nothing
Set myOutlApp=Nothing
rs.Edit
rs.MoveNext
Loop
End if
rs.Close
Ser rs=Nothing
Set db=Nothing
End Function
Hallo,
was ist der Sinn eines "leeren" MailItem-Objektes?
Zitat.
.
.
If Not rs.EOF And Not rs.BOF Then
rs.MoveFirst
Set myOutlApp=New Outlook.Application
Do While Not rs.EOF
Set myMail=myOutlApp.CreateItem(olMailItem)
With myMail
.To= ?? ?? ?? ?? ?? ?
.Subject= ?? ?? ?? ?? ?? ?
.Body= ?? ?? ?? ?? ?? ?? ?
.Send
End With
Set myMail=Nothing
rs.Edit
rs.MoveNext
Loop
Set myOutlApp=Nothing
End if
.
.
.
Hallo,
.To=Test@hotmail.com
.Subject=
.Body=""
Hallo,
führe die Funktion von Hand im VBA-Editor aus und setze vorher einen Haltepunkt an den Anfang des Codes. Fahre dann mit Einzelschritt weiter und prüfe dabei den Inhalt aller Variablen und die Logik des Code-Ablaufs.
M. E. fehlt im Body oder Betreff die Angabe, um welches Fahrzeug und welche Ladung (mit Datum) es sich bei einer individuellen Mail überhaupt handelt.
Prüfe zudem, ob der SQL-String (Recordset-Abfrage) überhaupt Daten liefert (liefern kann), indem das SQL-Statement in den Abfrage-Entwurf in die SQL-Ansicht einkopiert und ausgeführt wird.
Hallo,
vielen Dank klappt jetzt einwandfrei!