Depending on what you want to send them, or how. You can use something similar to this. I use this to send reports select from a previous form, and pass those perameters to this function to create and send the e-mails. Let me know if you need more help on this.....
Function SendEMail(ByVal strfile As String, strSubject As String, strMessage As String, strProp As String, intProc As Integer)
On Error GoTo SendErr
'************************************************* ********
'* Purpose: Sends E-Mail via Outlook *
'* Author: John Anthony *
'* Date Written: 5/29/03 *
'* Last Modified:6/5/03 *
'* Added in code to handle missing CC names*
'* 8/1/03 *
'* Functionality for E-mail IMCU tables *
'************************************************* ********
Dim olApp As Outlook.Application
Dim olMail As Outlook.MailItem
Dim olRecipient As Outlook.Recipient
Dim olCCRecipient As Outlook.Recipient
Dim blnKnownRecipient As Boolean
Dim db As Database
Dim rec As Recordset, rec2 As Recordset
Dim strSQL As String, strSQL2 As String
Dim Recipient As String, CCRecipient As String
Dim intAtt As Integer
Dim strF2 As String
Set db = CurrentDb()
If intProc = 1 Then '8/1/03
Set rec = db.OpenRecordset("tblDistributionListIMCU", dbOpenDynaset)
Set rec2 = db.OpenRecordset("tblDistributionListIMCUCC", dbOpenDynaset)
Else
strSQL = "SELECT * FROM tblDistributionList" & _
" WHERE (((tblDistributionList.PropertyCode)='" & strProp & "'));"
strSQL2 = "SELECT * FROM tblDistributionListCC" & _
" WHERE (((tblDistributionListCC.PropertyCode)='" & strProp & "'));"
Set rec = db.OpenRecordset(strSQL, dbOpenDynaset)
Set rec2 = db.OpenRecordset(strSQL2, dbOpenDynaset)
End If
Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)
With olMail
rec.MoveFirst
Do While rec.EOF = False
Recipient = rec.Fields("Distribution")
Set olRecipient = .Recipients.Add(Recipient)
olRecipient.Type = olTo
rec.MoveNext
Loop
If rec2.RecordCount > 0 Then
rec2.MoveFirst
Do While rec2.EOF = False
CCRecipient = rec2.Fields("Distribution")
Set olCCRecipient = .Recipients.Add(CCRecipient)
olCCRecipient.Type = olCC
rec2.MoveNext
Loop
End If
blnKnownRecipient = olRecipient.Resolve
.Subject = strSubject
If intProc = 1 Then '8/1/03
.Body = DLookup("[EMailBody]", "[tblEMailBody-IMCU]")
intAtt = DLookup("[Attachfile]", "[tblEMailBody-IMCU]")
Else
.Body = DLookup("[EMailBody]", "[tblEMailBody]")
intAtt = DLookup("[Attachfile]", "[tblEMailBody]")
End If
.Attachments.Add (strfile)
If intAtt = True Then
DoCmd.OpenForm "frmFileLocations", , , , , acHidden
strF2 = [Forms]![frmFileLocations].[Attachment]
'strF2 = "'" & strF2 & "'"
.Attachments.Add (strF2)
End If
'.Body = strMessage
If blnKnownRecipient = True Then
.Send
Else
.Display
End If
End With
Set olMail = Nothing
'olApp.Quit
'Set olApp = Nothing
SendEMail_Exit:
Exit Function
SendErr:
If Err.Number = 3021 Then
MsgBox "No Distribution List has been set up for the propery", vbCritical, "Missing Info"
Else
strmsg = Err.Description
MsgBox Err.Number & vbCrLf & Err.Description & vbCrLf & Err.Source
SendMail = False
Resume SendEMail_Exit
End If
End Function
John
|