Email from Access 2003

B

BigMick

I have been trying to send a reminder message to customers via email from
Access. The code I'm using is written below, but as You can probably see, I'm
a novice - self taught. Have tried the query name & feild name ie;
Qry_FilterReminder.Email & Also [Qry_FilterReminder]. but neither
work. Also as is written, Me.Email, but that cant find the feild. Have both
Outlook & Outlook Express on the system, prefer to use Outlook Express. Any
help would be greatly appreciated.

Cheers
BigMick

Private Sub FilterReminder_Click()
On Error GoTo ProcError

Dim stDocName As String

stDocName = "Qry_FilterReminder"
DoCmd.OpenQuery stDocName, acNormal, acEdit

DoCmd.SendObject To:=Nz(Me.Email, ""), Subject:="Septic Tank Filter", _
MessageText:=" Your septic tank filter is
due for it's annual clean. Regards, BigMick . Effluent Services"

ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure FilterReminder_Click..."
Resume ExitProc
Exit Sub

Exit_FilterReminder_Click:
Exit Sub

Err_FilterReminder_Click:
MsgBox Err.Description
Resume Exit_FilterReminder_Click

End Sub
 
T

Tom Wickerath

Hi Mick,

Why are you opening a query in code?
Dim stDocName As String

stDocName = "Qry_FilterReminder"
DoCmd.OpenQuery stDocName, acNormal, acEdit

I would comment out the above three lines.

Do you have a field in the form's recordset named Email? If not, you should
add it to the form's recordset. The Me part refers to the form, so Me.Email
refers to a field in the form's recordset named Email. It *does not* refer to
a field in the query that you are opening with the first three lines of code.

Also, this part does not look right:
Exit Sub

Exit_FilterReminder_Click:
Exit Sub

Err_FilterReminder_Click:
MsgBox Err.Description
Resume Exit_FilterReminder_Click

I would eliminate the lines of code shown above, so that your procedure
looks like this:

Private Sub FilterReminder_Click()
On Error GoTo ProcError

DoCmd.SendObject To:=Nz(Me.Email, ""), Subject:="Septic Tank Filter", _
MessageText:=" Your septic tank filter is
due for it's annual clean. Regards, BigMick . Effluent Services"

ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure FilterReminder_Click..."
Resume ExitProc
End Sub


And, make sure that Email is a field available to your form.

Are you using Option Explicit as the second line of code at the top of each
module?

Always Use Option Explicit
http://www.access.qbuilt.com/html/gem_tips.html#VBEOptions

Does your code compile without any errors (Debug > Compile ProjectName,
while in the VBA editor)?


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

BigMick said:
I have been trying to send a reminder message to customers via email from
Access. The code I'm using is written below, but as You can probably see, I'm
a novice - self taught. Have tried the query name & feild name ie;
Qry_FilterReminder.Email & Also [Qry_FilterReminder]. but neither
work. Also as is written, Me.Email, but that cant find the feild. Have both
Outlook & Outlook Express on the system, prefer to use Outlook Express. Any
help would be greatly appreciated.

Cheers
BigMick

Private Sub FilterReminder_Click()
On Error GoTo ProcError

Dim stDocName As String

stDocName = "Qry_FilterReminder"
DoCmd.OpenQuery stDocName, acNormal, acEdit

DoCmd.SendObject To:=Nz(Me.Email, ""), Subject:="Septic Tank Filter", _
MessageText:=" Your septic tank filter is
due for it's annual clean. Regards, BigMick . Effluent Services"

ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure FilterReminder_Click..."
Resume ExitProc
Exit Sub

Exit_FilterReminder_Click:
Exit Sub

Err_FilterReminder_Click:
MsgBox Err.Description
Resume Exit_FilterReminder_Click

End Sub[/QUOTE]
 

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

Top