473,757 Members | 9,145 Online
Bytes | Software Development & Data Engineering Community
+ 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(O ptional AttachmentPath)
Dim objOutlook As Outlook.Applica tion
Dim objOutlookMsg As Outlook.MailIte m
Dim objOutlookRecip As Outlook.Recipie nt
Dim objOutlookAttac h As Outlook.Attachm ent
On Error GoTo ErrorMsgs
' Create the Outlook session.
Set objOutlook = CreateObject("O utlook.Applicat ion")
' Create the message.
Set objOutlookMsg = objOutlook.Crea teItem(olMailIt em)
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.Ad d("train...@pos itivepets.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 = olImportanceHig h 'High importance
' Add attachments to the message.
If Not IsMissing(Attac hmentPath) Then
Set objOutlookAttac h = .Attachments.Ad d(AttachmentPat h)
End If
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
If Not objOutlookRecip .Resolve Then
objOutlookMsg.D isplay
End If
Next
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttac h = 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.c om/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!Trial Email) 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.OpenRecords et("select * from softwareUsers " &
whereStr)
If rstMail.RecordC ount = 0 Then GoTo exitCmdUserDeta ils
rstMail.MoveFir st
Do Until rstMail.EOF ' Begin loop
postIt = MsgBox(UserName & " " & rstMail!UserEma il & _
" ... " & rstMail!UserNam e & " ... " & _
rstMail!UserCom pany, 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.SendObjec t acSendNoObject, , acFormatTXT, _
rstMail!UserEma il, , , Me![SubjectReq], _
Me![GreetingReq] & " " & rstMail!UserNam e & _
Chr(10) & Chr(10) & Me![Instructions] & _
Chr(10) & Chr(10) & rstMail!UserCom ments
' Update the email sent box
rstMail.Edit
rstMail("EmailS ent") = True
rstMail.Update
Else
exitCmdUserDeta ils:
rstMail.Close
Exit Sub
End Sub
Thankyou,
Susan

Dec 20 '05 #1
5 2976
<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).O penRecordset("S ELECT...FROM... WHERE...",
dbOpenDynamic)
Set objOutlookMsg = objOutlook.Crea teItem(olMailIt em)

do until rsMsgInfo.EOF
with objOutlookMsg
.To = rsMsgInfo.Field s("EmailAddress ")
.Body = "Dear " & rsMsgInfo.Field s("FirstName"). ..
.Subject = "SOME SUBJECT:
.Send
rsMsgInfo.MoveN ext
Loop

rsMsgInfo.Close
set rsMsgInfo=Nothi ng

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

Dec 20 '05 #3
pi********@hotm ail.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).O penRecordset("S ELECT...FROM... WHERE...",
dbOpenDynamic)
Set objOutlookMsg = objOutlook.Crea teItem(olMailIt em)

do until rsMsgInfo.EOF
with objOutlookMsg
.To = rsMsgInfo.Field s("EmailAddress ")
.Body = "Dear " & rsMsgInfo.Field s("FirstName"). ..
.Subject = "SOME SUBJECT:
.Send
rsMsgInfo.MoveN ext
Loop

rsMsgInfo.Close
set rsMsgInfo=Nothi ng

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********@Fort uneJames.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********@Fort uneJames.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
3005
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 system for local asp testing development purposes and to allow satellite branches to ftp-in and grab images. I need to utilize the bulk emailing facility to send up to 20,000 emails a day after looping through my customer list which resides in...
1
4171
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 required to answer. A summary of the relevant code is: Dim mailObj as Outlook.MailItem
3
2366
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 email. Any ideas? Thanks in advance.
47
4543
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 company and this is a big decision for us(!) It's not just the money it's committing to an new version of Access!
7
3556
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. But when I did it, sending email code doesn`t work. Can you be so kind and give me the code how to send email with and without attachment in vb in Access 2003?? Thank you in advance
62
11417
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
4415
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 there, but is there a way they can find out if that application was put there from a CD or email or created at work? Hint: It's not on a client/server database, just native jet database mdb created on Access 2003 (default 2000)...
16
6199
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 using which sends If you want to see the above code in its full context you can see it here: http://www.thescripts.com/forum/thread581521.html Willakawill helped me out a bit with getting access to remember if it had already added the...
1
3834
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 Microsoft CDO for Windows 2000 under References. I can send one message and then if can close Access no problems. If I click the button several times to send several emails then Access hangs. I have to use task manager to kill it off. Either way,...
0
9489
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9298
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10072
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9885
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9737
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7286
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6562
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5172
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.