Here's the code that I use to send out notices from my A2K database. I hope this helps.
==================================================
Public Function EmailNotification()
On Error GoTo Message_Err
Dim strErrMsg As String 'For Error Handling
Dim olApp As New Outlook.Application
Dim olNameSpace As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Dim oleMsg As Object
'Data taken from listbox
Dim strFileName As String
Dim strReciprient As String, strResponsibleParty As String 'These are the same person
Dim strProject As String 'ActionDescription
Dim strFacility As String
Dim strFrequency As String
Dim strDueDate As String
Dim frm As Form
Dim sfN As Form 'Program Notification SubForm
'Gather information to put into body of message
Set frm = Forms!frmMainEntry.Form
Set sfN = frm.[fctlNotifications].Form
If sfN.[ProgramID] = sfN.[txtID] Then
strProject = sfN.ProgramDescription
strFacility = sfN.Facility
strDueDate = sfN.DueDate
strFrequency = sfN.FrequencyOfService
strReciprient = sfN.EmailAddress
strResponsibleParty = sfN.ResponsibleParty
strSender = frm!txtWelcome
Else
Exit Function
End If
'Create an email message to send.
Set olNameSpace = olApp.GetNamespace("MAPI")
Set olMail = olApp.CreateItem(olMailItem)
With olMail
.To = strReciprient
.BCC = "
[email protected]" & "; " & "
[email protected]" 'Send a blind copy
.Subject = "Notification Of Compliance Requirement"
.Body = vbCrLf & vbCrLf & vbCrLf & _
"To: " & strResponsibleParty & vbCrLf & vbCrLf & vbCrLf & _
"This is to notify you that the requirement for " & strProject & " at the " & _
strFacility & " is due on " & strDueDate & "." & vbCrLf & _
strProject & " is required " & strFrequency & "." & vbCrLf & vbCrLf & vbCrLf & _
"Keep On Track With Safety" & vbCrLf & strSender
.Importance = olImportanceHigh 'High importance
.ReadReceiptRequested = True
.Send
End With
Message_Exit:
Set olApp = Nothing
Set olMail = Nothing
Set oleMsg = Nothing
Exit Function
Message_Err:
Select Case Err
Case Else
strErrMsg = strErrMsg & "Error #: " & Format$(Err.Number) & vbCrLf & vbCrLf
strErrMsg = strErrMsg & "Error Description: " & Err.Description & vbCrLf
MsgBox strErrMsg, vbInformation, "Message"
Resume Message_Exit
End Select
End Function
==================================================