title: "RUN-TIME error '3085' Undefined Function 'EMAIL' in expression"
body: <p>I am using Access VBA code to automatically send emails through Outlook after a set amount of time.</p>
  
  <p>I keep getting a run-time error 3085. I do not know what went wrong or what function it is referring to. Is it possibly a reference I am missing or did I mess up on my functions somewhere?</p>
  
  <pre><code>Option Compare Database
  Sub SendMail()
  Dim db As DAO.Database
  Dim rs As DAO.Recordset
  
  Dim emailTo As String
  Dim emailSubject As String
  Dim emailText As String
  
  Dim outApp As Outlook.Application
  Dim outMail As Outlook.MailItem
  Dim outlookStarted As Boolean
  
  On Error Resume Next
  Set outApp = GetObject(, "Outlook.Application")
  On Error GoTo 0
  If outApp Is Nothing Then
  Set outApp = CreateObject("Outlook.Application")
  outlookStarted = True
  End If
  
  Set db = CurrentDb
  strSQL = "SELECT DATE, COMPANY, CUSTOMER, EMAIL(DISTRIBUTOR), FUP" &amp; _
    " FROM Sample Query WHERE DATE = (Date())"
  Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
  
  Do Until rs.EOF
  
    emailTo = Trim(rs.Fields("COMPANY").Value &amp; " " &amp; _
      rs.Fields("CUSTOMER").Value) &amp; _
      " &lt;" &amp; rs.Fields("EMAIL(DISTRIBUTOR)").Value &amp; "&gt;"
  
    emailSubject = "Proposal Follow Up"
    If IsNull(rs.Fields("COMPANY").Value) Then
        emailSubject = emailSubject &amp; " for " &amp; _
          rs.Fields("COMPANY").Value &amp; " " &amp; rs.Fields("CUSTOMER").Value
    End If
  
    emailText = Trim("Hello " &amp; rs.Fields("COMPANY").Value) &amp; "!" &amp; vbCrLf
  
    emailText = emailText &amp; _
      "We put an order on " &amp; rs.Fields("DATE").Value &amp; _
      " for " &amp; rs.Fields("COMPANY").Value &amp; _
      "A follow up would be good about now"
  
    Set outMail = outApp.CreateItem(olMailItem)
    outMail.To = emailTo
    outMail.Subject = emailSubject
    outMail.Body = emailText
    outMail.Send
  
    rs.Edit
    rs("FUP") = Now()
    rs.Update
  
    rs.MoveNext
  Loop
  
  rs.Close
  Set rs = Nothing
  Set db = Nothing
  
  If outlookStarted Then
      outApp.Quit
  End If
  
  Set outMail = Nothing
  Set outApp = Nothing
  End Sub
  </code></pre>