Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Mail From Email Address in Access Table, Containing Reoport 2

Status
Not open for further replies.

NWildblood

Technical User
Nov 12, 2007
113
GB
Hi
Does anyone know where I can find how to send email to an email address within an Access table field ? I'm running Lotus Notes and Access 2002, I can generate the mail with atttached report, but just don't have the coding experience to work this one any further... Any help very gratefully received !!!

I have bodged someone else's code within the narrow limits of me VB.
(Further to that if anyone know how to send a report as the email text body I would be thrilled!)
_________

Option Compare Database
_________
Private Sub cmdEmail_Click()
Call fEmailNotification
End Sub
_________

Private Function fEmailNotification()

Dim rs As DAO.Recordset
Dim strEmailTo As String
Dim strSubject As String
Dim strMessage As String

strSubject = "JOB NUMBER REQUEST"
strMessage = "Please find your job number as requested"

'email notification
Set rs = CurrentDb.OpenRecordset("Select 'EmailAddress:' from tJOBGENERATOR ")
rs.MoveFirst
While Not rs.EOF
'Just in case there are multiple records that have been flagged...
If strEmailTo <> "" Then
strEmailTo = strEmailTo & "; " & rs!Email
Else
'Im getting RunTime Errror 3265 here:
strEmailTo = rs!Email
End If
rs.MoveNext
Wend


DoCmd.SendObject acReport, "qOutPutJob", "RichTextFormat(*.rtf)", strEmailTo, "", "", "strSubject", "strMessage", False, ""

End Function

_________

I know I need to declare Email Recipient, Subject & Message properly etc, just haven't the knowledge... Corrections, pointers, links most welcome - many thanks again!

"No-one got everything done by Friday except Robinson Crusoe...
 
I would imagine you need to change

rs!email
to rs!emailaddress:

since emailaddress: is the field in the query

is emailaddress: the fieldname in the table

ck1999
 
Replace this:
Set rs = CurrentDb.OpenRecordset("Select 'EmailAddress:' from tJOBGENERATOR ")
with this:
Set rs = CurrentDb.OpenRecordset("Select [EmailAddress:] from tJOBGENERATOR ")

and this (2 times):
rs!Email
with this:
rs![EmailAddress:]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks guys, will try running this later today.

"No-one got everything done by Friday except Robinson Crusoe...
 
It works, thankyou both for your helpful corrections, I could't see the wood for the trees on Friday afternoon !

"No-one got everything done by Friday except Robinson Crusoe...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top