Can anyone tell or refer me. I’ve gotten this far with modifying code to generate and send an email from access.
How could I fix this code to make it loop through all the records in the form/recordset that’s open… and how can I fix the null error msg when someone doesn’t have an email address? ( i thought i was telling access to look at another table and grab the fax number instead) (i use microsoft fax to send faxes via outlook 97 with win95 as the OS). Thanks.
Option Compare Database
Option Explicit
Private Sub Command26_Click()
Dim appOutlook As New Outlook.Application
Dim lst As Access.TextBox
Dim strsql As String
Dim msg As Outlook.MailItem
Dim strBody As String
Dim strEMailRecipient
Dim strSubject As String
Dim strTo As String
On Error GoTo ErrorHandler
Set lst = Me![txtEmail]
If IsNull(lst) Then
lst.ControlSource = strsql
strsql = “SELECT tblDrPhone.DrPhone FROM tblDrPhone WHERE tblDrPhone.PhoneType = Like ‘ *fax*’ ”
End If
strEMailRecipient = lst.Value
strSubject = Me![txtSubject].Value
strBody = Me![txtBody].Value
Set msg = appOutlook.CreateItem(olMailItem)
With msg
.To = strEMailRecipient
.Subject = strSubject
.Body = strBody
.ReadReceiptRequested = True
.Display
‘.Send
End With
ErrorHandlerExit:
Exit Sub
ErrorHandler:
MsgBox “Error No: ” & Err.Number & “; Description: ” & Err.Description
Resume ErrorHandlerExit
End Sub