I just tried it with the changes you suggested and access displayed this msg
when i tried to run the macro, "the expression you entered has a function
name that STREAM cant find.
i will give you my code below just in case the mistake is in there.
Option Explicit
Public Function calemail(Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim FilePathStrg As String
Dim FileNameStrg As String
If DCount([Allocated To], [queries]![Cal Due Email]) > 0 Then
FilePathStrg = "C:\Documents and Settings\Brendan.Mills\Desktop\Equipment
DB\"
FileNameStrg = "Items due for calibration" & ".rtf"
If DoesFileExist(FilePathStrg & FileNameStrg) = True Then
Kill FilePathStrg & FileNameStrg
Else
End If
DoCmd.OutputTo acOutputReport, "Cal Due Email", acFormatRTF, FilePathStrg
& FileNameStrg, False
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message. Substitute
' your names here.
Set objOutlookRecip = .Recipients.Add("Matthew Horlock")
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("(e-mail address removed)")
objOutlookRecip.Type = olCC
' Set the Subject, Body, and Importance of the message.
.Subject = "Items Due For Calibration"
.Body = "This Email should contain an attachment with details of items
required for calibration, please forward on to whom it may concern." & vbCrLf
& vbCrLf
.Importance = olImportanceHigh 'High importance
' Add attachments to the message.
If IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add("C:\Documents and
Settings\Brendan.Mills\Desktop\Equipment DB\Items due for calibration.rtf")
End If
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing
Else: Exit Function
End If
End Function