C
cmichaud
I am having trouble an email module. When i run this it says that there
are too few parameters. That it was expecting 4. I assume that these
are the criteria that is feeding my query. Right now i have a form
with 4 comboboxes that provide the criteria for the query. I have a
button on the form that runs the query. I have not been able to
successfully relate this module to it...and running it on its own
doesnt work for some reason. Any ideas. I am trying to use the form
to filter for email addresses than send an email.
Public Function SendEMail()
Dim db As DAO.Database
Dim MailList As DAO.Recordset
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim Subjectline As String
Dim BodyFile As String
Dim fso As FileSystemObject
Dim MyBody As TextStream
Dim MyBodyText As String
Set fso = New FileSystemObject
Subjectline$ = InputBox$("Please enter the subject line for this
mailing.", _
"We Need A Subject Line!")
If Subjectline$ = "" Then
MsgBox "No subject line, no message." & vbNewLine & vbNewLine & _
"Quitting...", vbCritical, "E-Mail Merger"
Exit Function
End If
Set MyOutlook = New Outlook.Application
Set db = CurrentDb()
Set MailList = db.OpenRecordset("MyEmailAddresses")
Set MyMail = MyOutlook.CreateItem(olMailItem)
Do Until MailList.EOF
MailList.MoveNext
Loop
MyMail.Subject = Subjectline$
MyMail.Display
Set MyMail = Nothing
Set MyOutlook = Nothing
MailList.Close
Set MailList = Nothing
db.Close
Set db = Nothing
End Function
are too few parameters. That it was expecting 4. I assume that these
are the criteria that is feeding my query. Right now i have a form
with 4 comboboxes that provide the criteria for the query. I have a
button on the form that runs the query. I have not been able to
successfully relate this module to it...and running it on its own
doesnt work for some reason. Any ideas. I am trying to use the form
to filter for email addresses than send an email.
Public Function SendEMail()
Dim db As DAO.Database
Dim MailList As DAO.Recordset
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim Subjectline As String
Dim BodyFile As String
Dim fso As FileSystemObject
Dim MyBody As TextStream
Dim MyBodyText As String
Set fso = New FileSystemObject
Subjectline$ = InputBox$("Please enter the subject line for this
mailing.", _
"We Need A Subject Line!")
If Subjectline$ = "" Then
MsgBox "No subject line, no message." & vbNewLine & vbNewLine & _
"Quitting...", vbCritical, "E-Mail Merger"
Exit Function
End If
Set MyOutlook = New Outlook.Application
Set db = CurrentDb()
Set MailList = db.OpenRecordset("MyEmailAddresses")
Set MyMail = MyOutlook.CreateItem(olMailItem)
Do Until MailList.EOF
MailList.MoveNext
Loop
MyMail.Subject = Subjectline$
MyMail.Display
Set MyMail = Nothing
Set MyOutlook = Nothing
MailList.Close
Set MailList = Nothing
db.Close
Set db = Nothing
End Function