Here is some code to get you started. You will need to add a reference to
the Microsoft xx.x Outlook Object Library and the Microsoft DAO x.xx Object
Library appropriate to the version of Office that you are using.
Dim oApp As Outlook.Application
Dim objNewMail As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim rs As DAO.Recordset
Set oApp = New Outlook.Application
' Use the following if you want to send email
' to all of the records in a form
Set rs = Me.RecordsetClone
' or, use the following to use a query
' without a form
Set rs = CurrentDB.OpenRecordset("MyQueryName", DBOpenDynaset)
Set objNewMail = oApp.CreateItem(olMailItem)
With objNewMail
rs.MoveFirst
' All recipients will get the same email
Do While Not rs.EOF
If Len(Trim(rs!Email)) > 0 Then
Set objOutlookRecip = .Recipients.Add(rs!Email)
objOutlookRecip.Type = olTo
End If
rs.MoveNext
Loop
.Subject = "Test subject"
.Body = "Your text message here."
.Attachments = "Filename.xxxx"
.Save
.Send
End With
hth,
--
Cheryl Fischer
Law/Sys Associates
Houston, TX
Edu said:
I'd like to know how to send an e-mail directely from access, using a
query of names or for a single user.