473,403 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Sending Batch Email to Field Agents

I work for a large insurance company, and Im looking for a way to send emails with variable data to about 5,000 agents out in the field. (Not spam, I promise.)
Id like to use Access to pull info from various excel lists, and then send the results via email to our various agents.

I found some vb code online shown below, but Im a complete novice.
Im trying to find a way to change the code so it sends from an excel email list.

Will modifing the code show below serve my purposes, or should I look in some other direction?

Charlie
------------------------------------------

Public Sub SendMail()
'Provides the Send Mail automation
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strSubject As String
Dim strEmailAddress As String
Dim strEMailMsg As String
Dim ingCounter As Integer
Dim intCount As Integer

strSubject = "Latest Job Outcomes"
strEmailAddress = "charlie@xxxxx.com"
'strEmailAddress,replace [Mail Addresses Go Here] above with valid
'e-mail addresses
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("qrySendMail")


'Count of unsent e-mails
intCount = DCount("[lngJobOutcome]", "[tblJobOutcomes]" _
, "[ysnSentByMailToStaff]=0")
'If count of unsent e-mails is zero then the procedure will not run
'If count of unsent e-mails is greater than zero, msgbox will prompt
'to send mail.

If intCount = 0 Then
MsgBox ("You have " & intCount & " new job outcome e-mails to send.") _
, vbInformation, "System Information"
Exit Sub
Else

rst.MoveFirst
Do Until rst.EOF

strEMailMsg = rst![strStudentFirstName] & " " & rst![strStudentLastName] _
& " - " & rst![strStudentNumber] & " - " & " on the " & rst![strCourse] _
& " course" & " has informed us of a new job." & Chr(10) & Chr(10) _
& "Below are the details that have been submitted by the agent:" _
& Chr(10) & Chr(10) & rst![memNewJobDescription] & Chr(10) & Chr(10) _
& "Charlie"

'EMAIL USER DETAILS & ATT REPORT
DoCmd.SendObject , , acFormatRTF, strEmailAddress, _
, , strSubject, strEMailMsg, False, False


rst.MoveNext
Loop
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing

'Run update to update the sent mail check box
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblJobOutcomes SET tblJobOutcomes.ysnSentByMailToStaff = -1 WHERE (((tblJobOutcomes.ysnSentByMailToStaff)=0))"
DoCmd.SetWarnings True
MsgBox "All new Job Outcomes have been sent", vbInformation, "Thank You"
End If
End Sub
Apr 10 '07 #1
4 2549
ADezii
8,834 Expert 8TB
I work for a large insurance company, and Im looking for a way to send emails with variable data to about 5,000 agents out in the field. (Not spam, I promise.)
Id like to use Access to pull info from various excel lists, and then send the results via email to our various agents.

I found some vb code online shown below, but Im a complete novice.
Im trying to find a way to change the code so it sends from an excel email list.

Will modifing the code show below serve my purposes, or should I look in some other direction?

Charlie
------------------------------------------

Public Sub SendMail()
'Provides the Send Mail automation
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strSubject As String
Dim strEmailAddress As String
Dim strEMailMsg As String
Dim ingCounter As Integer
Dim intCount As Integer

strSubject = "Latest Job Outcomes"
strEmailAddress = "charlie@xxxxx.com"
'strEmailAddress,replace [Mail Addresses Go Here] above with valid
'e-mail addresses
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("qrySendMail")


'Count of unsent e-mails
intCount = DCount("[lngJobOutcome]", "[tblJobOutcomes]" _
, "[ysnSentByMailToStaff]=0")
'If count of unsent e-mails is zero then the procedure will not run
'If count of unsent e-mails is greater than zero, msgbox will prompt
'to send mail.

If intCount = 0 Then
MsgBox ("You have " & intCount & " new job outcome e-mails to send.") _
, vbInformation, "System Information"
Exit Sub
Else

rst.MoveFirst
Do Until rst.EOF

strEMailMsg = rst![strStudentFirstName] & " " & rst![strStudentLastName] _
& " - " & rst![strStudentNumber] & " - " & " on the " & rst![strCourse] _
& " course" & " has informed us of a new job." & Chr(10) & Chr(10) _
& "Below are the details that have been submitted by the agent:" _
& Chr(10) & Chr(10) & rst![memNewJobDescription] & Chr(10) & Chr(10) _
& "Charlie"

'EMAIL USER DETAILS & ATT REPORT
DoCmd.SendObject , , acFormatRTF, strEmailAddress, _
, , strSubject, strEMailMsg, False, False


rst.MoveNext
Loop
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing

'Run update to update the sent mail check box
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblJobOutcomes SET tblJobOutcomes.ysnSentByMailToStaff = -1 WHERE (((tblJobOutcomes.ysnSentByMailToStaff)=0))"
DoCmd.SetWarnings True
MsgBox "All new Job Outcomes have been sent", vbInformation, "Thank You"
End If
End Sub
Will this Excel E-Mail list consist of Recipient Names and comprise strEmailList?
Apr 12 '07 #2
Will this Excel E-Mail list consist of Recipient Names and comprise strEmailList?
Yes.

What I would ultimately like to do is be able to extract email addresses and other data from and excel database in access, and then send emails to all the agents from that excel list using an access form with buttons.

I was thinking I just need to find a variable to use in place of the static email address after the strEmailAddress as shown below, but there is probably much more I need to change.

strSubject = "Latest Job Outcomes"
strEmailAddress = "chawea@xxxxx.com"
'strEmailAddress,replace [Mail Addresses Go Here] above with valid
'e-mail addresses
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("qrySendMail")
Apr 24 '07 #3
ADezii
8,834 Expert 8TB
Yes.

What I would ultimately like to do is be able to extract email addresses and other data from and excel database in access, and then send emails to all the agents from that excel list using an access form with buttons.

I was thinking I just need to find a variable to use in place of the static email address after the strEmailAddress as shown below, but there is probably much more I need to change.

strSubject = "Latest Job Outcomes"
strEmailAddress = "chawea@xxxxx.com"
'strEmailAddress,replace [Mail Addresses Go Here] above with valid
'e-mail addresses
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("qrySendMail")
What you need to do first is to Import a sample Excel List into Access and display the structure of it. Hopefully, we can advance from that point on.
Apr 24 '07 #4
I imported the excel email list as a table. I named the table tblEmailAddresses.
Then I replaced the static email address shown below to "[tblEmailAddresses]" and that didnt work. Next I tried "strEmailAddresses" after naming the column header in my excel file strEmailAddresses, and that didnt work.

Im just grabbing in the dark because Im brand spankin new. Im trying to think this through logically, but Im not getting very far yet. I really didnt think this was going to be very hard, and it probably isnt once I get headed in the right direction.

I appreciate your help,

Charlie

strEmailAddress = "chawea@xxxxx.com"
Apr 25 '07 #5

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

Similar topics

10
by: Stuart Mueller | last post by:
I have an exchange server, that I sometimes use to perform mail shots to clients on our database, these can be upwards of 1000 at a time. As we don't want different clients to see who we are...
4
by: Sam | last post by:
Hello everyone, I have around 20 reports in an ASP web-application which connects to a SQL Server 2000 dB, executes stored procedures based on input parameters and returns the data in a nice...
20
by: CHIN | last post by:
Hi all.. here s my problem ( maybe some of you saw me on other groups, but i cant find the solution !! ) I have to upload a file to an external site, so, i made a .vbs file , that logins to...
2
by: kimberly.shaffer | last post by:
Okay, I can automate sending of multiple emails with records using Groupwise and Access DB. But now what I need to do is send multiple fields associated with one field out automatically and can't...
2
by: eric1025 | last post by:
I have a form with a command button. When the command button is clicked, it runs a batch file via the Shell command. The batch file is run with a few variables coming from the database such as %1...
1
by: simon.robin.jackson | last post by:
Ok. I have a database. I have a report. I want to batch export this report to either html/xml/rtf files. However, at present, the problem is that by default, I can batch export to html but it will...
8
alpnz
by: alpnz | last post by:
Hi, I have a need to send snap reports to various shipping agents. E.g. A PalletCard, A FreightNote, A Consignment Advice, and an Export declaration of Conformity. It is easy enough to code a...
7
by: bleachie | last post by:
Hey, I just need some help, my form seems to not send me all of the 'guestNames' and 'guestEmails' forms. i use this function to add more guestnames and guestemail fields based on the number of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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:
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...

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.