I am missing something. I am trying to output a single record into an email. I have it outputting the whole table. Can someone review and possibly push me in the right direction.
Private Sub Command65_Click()
Dim stDocName As String
Dim sFilter As String
Dim strPath As String
Dim strTemp As String
Dim strBody As String
Dim strEmail As String
strPath = DLookup("TextPath", "tbl_PathInfo")
strEmail = DLookup("EmailAddress", "tbl_EmailAddresses")
sFilter = "CallLogID = Forms!ServiceLog!CallLogID"
Dim EmailApp, NameSpace, EmailSend As Object
DoCmd.OutputTo acReport, "Email", acFormatTXT, strPath
Open strPath For Input As #1
Do Until EOF(1)
Line Input #1, strTemp
strBody = strBody & strTemp & vbCrLf
Loop
Close #1
Set EmailApp = CreateObject("Outlook.Application")
Set NameSpace = EmailApp.getNameSpace("MAPI")
Set EmailSend = EmailApp.CreateItem(0)
EmailSend.TO = strEmail
EmailSend.subject = [SearchName]
EmailSend.Display
EmailSend.Body = strBody
Set EmailApp = Nothing
Set NameSpace = Nothing
Set EmailSend = Nothing
Kill strPath
End Sub
Private Sub Command65_Click()
Dim stDocName As String
Dim sFilter As String
Dim strPath As String
Dim strTemp As String
Dim strBody As String
Dim strEmail As String
strPath = DLookup("TextPath", "tbl_PathInfo")
strEmail = DLookup("EmailAddress", "tbl_EmailAddresses")
sFilter = "CallLogID = Forms!ServiceLog!CallLogID"
Dim EmailApp, NameSpace, EmailSend As Object
DoCmd.OutputTo acReport, "Email", acFormatTXT, strPath
Open strPath For Input As #1
Do Until EOF(1)
Line Input #1, strTemp
strBody = strBody & strTemp & vbCrLf
Loop
Close #1
Set EmailApp = CreateObject("Outlook.Application")
Set NameSpace = EmailApp.getNameSpace("MAPI")
Set EmailSend = EmailApp.CreateItem(0)
EmailSend.TO = strEmail
EmailSend.subject = [SearchName]
EmailSend.Display
EmailSend.Body = strBody
Set EmailApp = Nothing
Set NameSpace = Nothing
Set EmailSend = Nothing
Kill strPath
End Sub