473,662 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Send emails to users stored on each record

27 New Member
Hey all i am using Access 2003 on Win Xp and i have been trying to make this code send emails to the users stored on each record. So far is works, except in the body of the email i need it to say a number of things, such as Dear (user), your current quota is (quota), and so on.

So far i can send the emails to multiple users but when it comes down to writing the message i cannot enter in more than one "rec("field )".

In my database i have four fields which are labeled Email, User, Name, Surname.

This code is VB btw

Thank you

Here is the code:

Expand|Select|Wrap|Line Numbers
  1. Public Sub SendMessage()
  2.  
  3. Dim ol As Outlook.Application
  4. Dim msg As MailItem
  5. Dim rec As DAO.Recordset
  6. Dim intCount As Integer
  7. Dim intLoop As Integer
  8.  
  9.  
  10.  
  11.  
  12.  
  13. Set ol = New Outlook.Application
  14.  
  15. Set rec = CurrentDb.OpenRecordset("q1")
  16. If Not (rec.BOF And rec.EOF) Then
  17. rec.MoveLast
  18. rec.MoveFirst
  19. intCount = rec.RecordCount
  20. For intLoop = 1 To intCount
  21. Set msg = ol.CreateItem(olMailItem)
  22. msg.Subject = "ENTER YOUR SUBJECT HERE"
  23. msg.To = rec("Email")
  24. msg.Body =
  25. msg.Send
  26. Set msg = Nothing
  27. rec.MoveNext
  28. Next intLoop
  29. End If
  30.  
  31. Set rec = Nothing
  32. Set ol = Nothing
  33.  
  34. End Sub
  35.  
Feb 7 '07 #1
6 2671
MMcCarthy
14,534 Recognized Expert Moderator MVP
Try this ...

Expand|Select|Wrap|Line Numbers
  1. Public Sub SendMessage()
  2.  
  3. Dim ol As Outlook.Application
  4. Dim msg As MailItem
  5. Dim rec As DAO.Recordset
  6. Dim intCount As Integer
  7. Dim intLoop As Integer
  8.  
  9. Set ol = New Outlook.Application
  10.  
  11. Set rec = CurrentDb.OpenRecordset("q1")
  12. If Not (rec.BOF And rec.EOF) Then
  13. rec.MoveLast
  14. rec.MoveFirst
  15. intCount = rec.RecordCount
  16. For intLoop = 1 To intCount
  17. Set msg = ol.CreateItem(olMailItem)
  18. msg.Subject = "ENTER YOUR SUBJECT HERE"
  19. msg.To = rec("Email")
  20. msg.Body = "Dear " & rec("User") & "," & vbCrLf & "Your current quota is: " & _
  21. rec("quota") & "." & vbCrLf & "Everthing else you want to say."
  22. msg.Send
  23. Set msg = Nothing
  24. rec.MoveNext
  25. Next intLoop
  26. End If
  27.  
  28. Set rec = Nothing
  29. Set ol = Nothing
  30.  
  31. End Sub
  32.  
Mary
Feb 7 '07 #2
slider
27 New Member
Hey! Thank you so much! Your so awesome! Ive been going nuts for the past few days trying to figure it out. I did try using the "&" but i was typing "and"! haha silly me

once again thank you and im sure i will be back for more answers

Jordy
Feb 7 '07 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
Hey! Thank you so much! Your so awesome! Ive been going nuts for the past few days trying to figure it out. I did try using the "&" but i was typing "and"! haha silly me

once again thank you and im sure i will be back for more answers

Jordy
You're Welcome Jordy.

Glad it's working for you.

Mary
Feb 7 '07 #4
slider
27 New Member
hmm well yes it works, the only problem now is that i have to wait 5 seconds and click yes for every email that gets sent...im using Microsoft Outlook 2003 and its some security feature.

is there anyway around this or anyway i can change the code to use another program or bypass the security?
Feb 7 '07 #5
MMcCarthy
14,534 Recognized Expert Moderator MVP
hmm well yes it works, the only problem now is that i have to wait 5 seconds and click yes for every email that gets sent...im using Microsoft Outlook 2003 and its some security feature.

is there anyway around this or anyway i can change the code to use another program or bypass the security?
Unfortunately, this is not a straightforward question. Have a look at this MSDN site.

Mary
Feb 7 '07 #6
NeoPa
32,568 Recognized Expert Moderator MVP
If you dig around in here there are threads that use a different technique for sending e-mails. I would guess they send via SMTP. If so, there are different methods of combatting spam on a network for SMTP. So you wouldn't have the 5 second delay - but they may be blocked completely depending on how your network has been set up.
Feb 7 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
3172
by: Toby Newman | last post by:
Hi, I run a community website (forum and wiki) that is updated perhaps once every 10 minutes by a user. My bandwidth usage is quite high because the 40 users generally sit there pressing F5 to see if anything has been added. I do keep images small, but still... I wonder, would it be possible using PHP (or cgi, or whatever, really,
4
4806
by: Thom McGrath | last post by:
I'm writing a simple mailing list program, and I would like to know what the suggested method of sending a large number of emails to a list of addresses. (sounds like spam, no?) It's perfectly legit, it's just an opt-in mailing. I have a feeling that using a 'while' loop with repeated calls to mail() is not the best practice. Is there something better I should be doing?
1
5858
by: Gernot Hillier | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi! I'm the developer of a Linux ISDN application which uses embedded Python for controlling the communication. It starts several threads (i.e. one for each incoming call and for outgoing faxes) which run Python scripts in embedded Python interpreters which in turn do the real communication stuff. Any incoming data or confirmations of done jobs are sent via Email.
2
3319
by: serendipity | last post by:
Hi, I'm not sure if this is possible as i've googled everywhere, but i have a select query that returns a customer record with their associated sales orders. I would like to automate a process which sends an email reminder to each customer in the database, that has outstanding orders. This email reminder should have the results of the query regarding their account. The table structure are as follows.
2
6421
by: Larisa | last post by:
Hello everyone, I need advice of how to accomplish the following: Loop though records in a table and send an email per record. Email recipient, message text and attachment file name - that's all changes record by record. Is it doable from a stored procedure (easily I mean, or am I better off writing a VB app)? There are so many options of sending mail from SQL server - CDONTS, SQL MAIL TASK, xp_sendmail. What's easier to implement
0
988
by: Nathan Truhan | last post by:
Hello, I have a WinForms application to send out emails to a large group of students. This is not spam, but mail from our university to the students. Currentl I have a ListView with 4 columns Email, FirstName, MiddleName, LastName. I also have a form that will load users into this listview from a number of different places defined by ODBC. The population of this listview works perfectly, however with a small number of users, the...
4
7675
by: =?Utf-8?B?dHBhcmtzNjk=?= | last post by:
I have a web page that at the click of a button must send a bunch (1000+) emails. Each email is sent individually. I have the code working fine, using Mail Message classes and smtp and all that. But sometimes even when I'm just sending one e-mail the web page takes a minutes or so to post. Can anyone tell me why it is so slow, or how to fix the problem? To address this I am thinking of just creating a queue table to write the emails...
5
4092
by: pat | last post by:
Hi, i'am using an ac2K progrom which sends automaticle emails with an attachment. Since last week , a error occurs with number 2293. Our mail program is Outlook 2003. It's probably a matter of safety in outlook, but i didn't saw an answer to prevent this error on theweb. Where can i configure the safetyitem that Outlook sees the mail not langer
2
2125
by: jcrum00 | last post by:
My asp script used to be able to send email to an unlimited amount of users. But a couple weeks ago I started getting this error message "transport failed to connect to server". So I increased the smtp connection timeout. Then I started getting an error saying the maximum amount of time for my script to run had been reached. So I increased Sever.ScriptTimeout. Now I'm just getting a generic error message saying my page cannot be...
0
8343
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
8856
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
8545
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
7365
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6185
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
4179
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...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1992
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.