Error sending emails from Access through Outlook...



I am having the typical problem when sending an email from Access. I get
that error saying that another application is trying to send an email on my
behalf or whatever. I heard that it can be bypassed by using sendObject, is
this true? If so, how would i modify my code to use this.

Function Email()
'Set reference to Outlook
On Error GoTo Errhandler
'Dim strBCC As String
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim objOutl As Outlook.Application
'Dim objEml As Outlook.MailItem
Dim i As Integer

Set db = CurrentDb
Set rst = db.OpenRecordset("qryEmailReminder", dbOpenSnapshot)

Set objOutl = CreateObject("Outlook.application")
'Set objEml = objOutl.createItem(olMailitem)

With rst
If .RecordCount > 0 Then
End If
End With

For i = 1 To rst.RecordCount
If Len(rst!EmployeeEmail) > 0 Then
strTo = rst!EmployeeEmail
Dim objEml As Outlook.MailItem
Set objEml = objOutl.createItem(olMailitem)

With objEml
.To = strTo

.Subject = rst!Action & " Today"

.Body = rst!Action & " with " & rst!Contact & " of " &
rst!Company & vbCrLf & "Notes: " & rst!Comments

.Importance = olImportanceHigh

End With
End If
Set objEml = Nothing
Next i

Set objOutl = Nothing
'Set objEml = Nothing
Set rst = Nothing
Set db = Nothing
Exit Function

MsgBox Err.Number & ": " & Err.Description
Resume ExitHere

End Function

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question