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: - Public Sub SendMessage()
-
-
Dim ol As Outlook.Application
-
Dim msg As MailItem
-
Dim rec As DAO.Recordset
-
Dim intCount As Integer
-
Dim intLoop As Integer
-
-
-
-
-
-
Set ol = New Outlook.Application
-
-
Set rec = CurrentDb.OpenRecordset("q1")
-
If Not (rec.BOF And rec.EOF) Then
-
rec.MoveLast
-
rec.MoveFirst
-
intCount = rec.RecordCount
-
For intLoop = 1 To intCount
-
Set msg = ol.CreateItem(olMailItem)
-
msg.Subject = "ENTER YOUR SUBJECT HERE"
-
msg.To = rec("Email")
-
msg.Body =
-
msg.Send
-
Set msg = Nothing
-
rec.MoveNext
-
Next intLoop
-
End If
-
-
Set rec = Nothing
-
Set ol = Nothing
-
-
End Sub
-
6 2671 MMcCarthy 14,534
Recognized Expert Moderator MVP
Try this ... -
Public Sub SendMessage()
-
-
Dim ol As Outlook.Application
-
Dim msg As MailItem
-
Dim rec As DAO.Recordset
-
Dim intCount As Integer
-
Dim intLoop As Integer
-
-
Set ol = New Outlook.Application
-
-
Set rec = CurrentDb.OpenRecordset("q1")
-
If Not (rec.BOF And rec.EOF) Then
-
rec.MoveLast
-
rec.MoveFirst
-
intCount = rec.RecordCount
-
For intLoop = 1 To intCount
-
Set msg = ol.CreateItem(olMailItem)
-
msg.Subject = "ENTER YOUR SUBJECT HERE"
-
msg.To = rec("Email")
-
msg.Body = "Dear " & rec("User") & "," & vbCrLf & "Your current quota is: " & _
-
rec("quota") & "." & vbCrLf & "Everthing else you want to say."
-
msg.Send
-
Set msg = Nothing
-
rec.MoveNext
-
Next intLoop
-
End If
-
-
Set rec = Nothing
-
Set ol = Nothing
-
-
End Sub
-
Mary
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
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
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?
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
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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,
|
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?
|
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.
|
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.
|
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
| |
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...
|
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...
|
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
|
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...
|
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,...
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |