473,473 Members | 2,080 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

MS Access 2003 sending emails

Hello,
Below is what I "Know how to do" but it doesn't accomplish what I want

I have table called sndmail fields that matter useremail and mailsent
I need to get the sendmessage to loop through to EOF and only send
emails to those with mailsent field "NO"
I know how to get access to send emails using:
Option Explicit
Sub sbSendMessage(Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
On Error GoTo ErrorMsgs
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message. Substitute
' your names here.
Set objOutlookRecip = .Recipients.Add("positivep...@aim.com")
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
Set objOutlookRecip =
..Recipients.Add("train...@positivepets.net")
objOutlookRecip.Type = olBCC
' Set the Subject, Body, and Importance of the message.
.Subject = "This is an Automation test with Microsoft Outlook"
.Body = "Last test." & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance
' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing
ErrorMsgs:
If Err.Number = "287" Then
'MsgBox "You clicked No to the Outlook security warning. " & _
"Rerun the procedure and click Yes to access e-mail" & _
"addresses to send your message. For more information, & _
"see the document at http://www.microsoft.com/office" & _
"/previous/outlook/downloads/security.asp. " "
Else
'MsgBox Err.Number, Err.Description'
End If
End Sub
I also found this that is supposed to perform Exactly what I want but
it bombs with 'improper use of my and other errors PLEASE help:
Private Sub emailList_Click()
' Loop through a email list generate messages one at a time
Dim dbs As Database, whereStr As String
Dim rstMail As Recordset, UserEmail As Variant
Dim postIt As Integer, UserName As Variant
Dim UserCompany As Variant, UserCountry As Variant
Dim UserComments As Variant, AccessVersion As Variant
Dim EmailDownload As Variant
If Not IsNull(Me!TrialEmail) Then
' Just do a single trial email
whereStr = " where userEmail = '" & Me!TrialEmail & "'"
Me!TrialEmail = Null
Else
' Email the list one at a time
whereStr = " where not emailSent "
End If
' Open the database object and select users names that havent been sent

yet
Set dbs = CurrentDb
Set rstMail = dbs.OpenRecordset("select * from softwareUsers " &
whereStr)
If rstMail.RecordCount = 0 Then GoTo exitCmdUserDetails
rstMail.MoveFirst
Do Until rstMail.EOF ' Begin loop
postIt = MsgBox(UserName & " " & rstMail!UserEmail & _
" ... " & rstMail!UserName & " ... " & _
rstMail!UserCompany, vbYesNoCancel, _
"Email The Following"
If postIt = vbYes Then
' Output the message as email. Build a complete email message
' from the user detail and the message on the output form
' Place the user comments at the bottom so that you can refer
' to them for that personal message !
DoCmd.SendObject acSendNoObject, , acFormatTXT, _
rstMail!UserEmail, , , Me![SubjectReq], _
Me![GreetingReq] & " " & rstMail!UserName & _
Chr(10) & Chr(10) & Me![Instructions] & _
Chr(10) & Chr(10) & rstMail!UserComments
' Update the email sent box
rstMail.Edit
rstMail("EmailSent") = True
rstMail.Update
Else
exitCmdUserDetails:
rstMail.Close
Exit Sub
End Sub
Thankyou,
Susan

Dec 20 '05 #1
5 2954
<SNIP>
I have table called sndmail fields that matter useremail and mailsent

I need to get the sendmessage to loop through to EOF and only send
emails to those with mailsent field "NO"
</SNIP>

"SELECT <Fieldlist> from MyTable WHERE MailSent=False;"
- open that recordset, loop through it, send e-mails to each. It's
already filtered.

the problem with CurrentDB is that it's in the DAO object library, and
if you're using some versions of Access (2000, maybe 2002), only ADO is
registered by default. So you need to register it. OPen a code
module, Tools-References-find DAO 3.x... and click it. Then if you
need to have both ADO and DAO registered (checked), then you need ti
disambiguate your references. For example...

dim rsDAO as DAO.Recordset
dim rsADO as ADO.Recordset

HTH

Dec 20 '05 #2
Just reading this message is getting me confused. So I'll look at the
first example (automating Outlook) instead of the second (using
SendObject).

Here's my simplified example...
dim rsMsgInfo as DAO.Recordset
dim objOutlookMsg as object

Set rsMsgInfo = dgengine(0(0).OpenRecordset("SELECT...FROM...WHERE ...",
dbOpenDynamic)
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

do until rsMsgInfo.EOF
with objOutlookMsg
.To = rsMsgInfo.Fields("EmailAddress")
.Body = "Dear " & rsMsgInfo.Fields("FirstName")...
.Subject = "SOME SUBJECT:
.Send
rsMsgInfo.MoveNext
Loop

rsMsgInfo.Close
set rsMsgInfo=Nothing

Hopefully that's more helpful than the last oh so very helpful post...
Pieter

Dec 20 '05 #3
pi********@hotmail.com wrote:
Just reading this message is getting me confused. So I'll look at the
first example (automating Outlook) instead of the second (using
SendObject).

Here's my simplified example...
dim rsMsgInfo as DAO.Recordset
dim objOutlookMsg as object

Set rsMsgInfo = dgengine(0(0).OpenRecordset("SELECT...FROM...WHERE ...",
dbOpenDynamic)
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

do until rsMsgInfo.EOF
with objOutlookMsg
.To = rsMsgInfo.Fields("EmailAddress")
.Body = "Dear " & rsMsgInfo.Fields("FirstName")...
.Subject = "SOME SUBJECT:
.Send
rsMsgInfo.MoveNext
Loop

rsMsgInfo.Close
set rsMsgInfo=Nothing

Hopefully that's more helpful than the last oh so very helpful post...
Pieter


You're doing a great job Piet and getting better all the time. I would
have added a few more errors than you did just to make sure that the
one-time poster is a programmer and not a SPAMMER. I'd hate to get
emailed an advertisement for something like pet training. It's not too
late to say, "Oops" and add some disinformation :-). Yet you gave
enough information that a programmer can get past the biggest hurdle.
Well done.

James A. Fortune
CD********@FortuneJames.com

Dec 20 '05 #4
Actually I do 'horse training, transportation and I happen to really
like to use ms access and dable with asp to make my life 'easier' (hah
somewhat funny since I am SOOOOOO Slow compared to you guys that are
the masters :)

I know positivepets probably is VERY funny on a db group :)

Thank you for taking the time to answer my post and I will let you know
if the responses gets me where I need to be but I have to get the email
addresses from the table not manually type them!

Thanks and oh by the way I am not using this to 'telemarket' or
whatever you would call it - rather I am using this to reply to people
who Post a request for training/transport to my website!!!!

Dec 20 '05 #5
horsetransport wrote:
Actually I do 'horse training, transportation and I happen to really
like to use ms access and dable with asp to make my life 'easier' (hah
somewhat funny since I am SOOOOOO Slow compared to you guys that are
the masters :)

I know positivepets probably is VERY funny on a db group :)

Thank you for taking the time to answer my post and I will let you know
if the responses gets me where I need to be but I have to get the email
addresses from the table not manually type them!

Thanks and oh by the way I am not using this to 'telemarket' or
whatever you would call it - rather I am using this to reply to people
who Post a request for training/transport to my website!!!!


Thanks.

James A. Fortune
CD********@FortuneJames.com

Seen on a bumper sticker:
My Labrador is smarter than your honor student.

Dec 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: jason | last post by:
What are the technical challenges in getting a local SMTP email server set up on a win3k system or alternatively on a win2k pro local work statation. We are on the verge of acquiring a new win3k...
1
by: Devonish | last post by:
I am composing an email with Access VB and then sending it from within Access. Everything works correctly (the email actually goes!) but Outlook ask some irritating questions that the user is...
3
by: Strasser | last post by:
In Access2000 mass emailing worked perfectly (very powerful tool!). Doesn't work when using XP version of both Access and Outlook, even though I checked the box to ensure that I was sending the...
47
by: ship | last post by:
Hi We need some advice: We are thinking of upgrading our Access database from Access 2000 to Access 2004. How stable is MS Office 2003? (particularly Access 2003). We are just a small...
7
by: Marcin | last post by:
Hello all! A few years ago I created a form with button which let me send an email with an attachment. It was created in Access 97. Now I would like to move this application into Access 2003....
62
by: Ecohouse | last post by:
I was just wondering if there was any way to use a toolbar in Outlook 2002 in Access 2002? I want to create a custom toolbar in Access similar to the Calendar toolbar in Outlook. Any ideas?
17
by: Mell via AccessMonster.com | last post by:
Is there a way to find out where an application was created from? i.e. - work or home i.e. - if application sits on a (work) server/network, the IT people know the application is sitting...
16
by: Kosmos | last post by:
Good afternoon everyone, just wondering if anyone knew if it's possible to send meetings or appointments through email when you run VBA or SQL code in Access 2003? The following is the code I've been...
1
by: TD | last post by:
I have the code below under a button on a form. At this point am just testing how to send email from MS Access. Access is installed on a machine running WinXP Pro. I checked the box next to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.