Can I get Outlook addresses from Access 2007 query?

Not open for further replies.

Ron Carr

I would like to be able to send an email to the addresses which result from an Access query.

I do NOT want them permantenly in Outlook contacts.

Can this be done? How?

Yes I can write VBA if I have a clue how to do this.



Jennifer Zhan

Hi Ron,

Think something like this will work for you. You can set this up on a button or a timer, or what-have-you.


Dim MyDb As DAO.Database Dim rsEmail As DAO.Recordset Dim sToName As String Dim sSubject As String Dim sMessageBody As String Set MyDb = CurrentDb() Set rsEmail = MyDb.OpenRecordset("qryQueryName", dbOpenSnapshot) With rsEmail .MoveFirst Do Until rsEmail.EOF If IsNull(.Fields(x)) = False Then sToName = .Fields(x) sSubject = "Invoice #: " & .Fields(y) sMessageBody = "Email Body Text " & vbCrLf & _ "Field A: " & .Fields(a) & vbCrLf & _ "Field B: " & .Fields(b) & vbCrLf & _ "Field C: " & .Fields(c) DoCmd.SendObject acSendNoObject, , , _ sToName, , , sSubject, sMessageBody, False, False End If .MoveNext Loop End With Set MyDb = Nothing Set rsEmail = Nothing

You can test this on a button, but here is what goes down ...

First, look at your query and see how your columns are defined. Note, the order of your fields, for instance if the e-mail address is in the first column, that column index is 0 (the query columns go from 0 to n).

Note a recordset uses the term 'fields' for columns so assign the correct field/column numbers in the above code:


qryQueryName = the name of the query you want to send e-mails from
x = # of the field with e-mail address
y = # of field with invoice number
a,b,c = # of fields if you want the e-mail body to have more information from the query (if not/more, you can delete/add as appropriate)

With (y), I put the invoice number in the subject line - you can move it whereever, just wanted to give you a good enough example to work off of.
Also, I had it check field(x) (the email field) to see if there was an e-mail there, if not, it ignores that record.

Hope that helps.

Not open for further replies.
Thread starter Similar threads Forum Replies Date
D Outlook 2003 - A program is trying to access e-mail addresses Outlook VBA and Custom Forms 5
S how to disable outlook security messages "A program is trying to access e-mail addresses you have st Using Outlook 5
M possible to search Outlook for multiple email addresses at once? Using Outlook 1
RBLampert Outlook 2010 sends to/receives from some Gmail addresses but not others Using Outlook 3
A Sending Emails Through Outlook From Multiple Email Addresses Using Outlook 1
Caio "From" field doesn't show extra email addresses in Outlook 2016. Using accounts in Outlook 6
A Outlook Postal Addresses Missing/Blank Using Outlook 0
R Outlook Office 365 not saving addresses Using Outlook 0
L Outlook 2007 Delete Email Addresses Using Outlook 19
Z Outlook 2007, clicking email addresses fails to open Contact Using Outlook 0
D Outlook 2013 wont send to over 3 addresses Using Outlook 1
D Outlook 2007 Custom Form - Dual Addresses and Mailing Address Using Outlook 6
R Can not send a newsletter to a group. Does not appear Outlook 2007 is recognizing the email addresses. Using Outlook 2
B Outlook 2007, must modify incomming e-mail addresses to reply Using Outlook 3
B How to remove underline from email addresses in outlook 2007 and Autotext also missing Using Outlook 2
I Outlook inputs addresses for contacts incorrectly Using Outlook 4
G Multiple email addresses (Outlook 2002). All emails (both addresses) go into the one inbox. How do i Using Outlook 3
D Outlook 2003 won't send emails to gmail or yahoo addresses Using Outlook 2
J Outlook Auto Suggest Email Addresses Using Outlook 2
I Outlook 2002 - Out of memory & system resources. Also not recognising typed in email addresses. Using Outlook 3
I Outlook 2007 showing 2 e-mail addresses instead of 1 when sending e-mail to recipients using Outlook 2007. Using Outlook 2
S Outlook 2007 Old addresses pop up Using Outlook 2
M Need to take names and email addresses from excel 2003 and put into outlook to email. Using Outlook 4
J Printing Outlook Contacts as addresses on envelopes Using Outlook 1
G Deleting bounced back bad destination email addresses from Outlook's Contact Using Outlook 1
R Outlook 2010 - corrupting email addresses from websites or other programs Using Outlook 3
D When enver I include more than about three recipient email addresses in TO or BCC Outlook shuts down. Using Outlook 1
M Inverted Commas Around Email Addresses In Sent Items - Outlook 2007 Using Outlook 2
S AutoComplete addresses lost in Outlook 2010 Using Outlook 1
D more than 200 email addresses at a time in Outlook 2007 Using Outlook 1
T Outlook 2007: outgoing email with addresses taken from address book won't send Using Outlook 9
V outlook 2007 autocomplete not working when typing in addresses Using Outlook 3
T How to stop outlook from auto populating names when i type email addresses Using Outlook 1
K Imported Address Books from Thunderbird to Outlook 2010 not showing email addresses. How do I get t Using Outlook 1
L Outlook for Mac 2011 - How do I get the recent addresses moved from Outlook for Windows 2007 (.nk2 f Using Outlook 2
B Outlook 2010 - Can't send to new addresses Using Outlook 6
E Outlook is not remembering e-mail addresses Using Outlook 2
G Outlook Social Connector and multiple email addresses Using Outlook 3
R Possible to setup multiple reply from addresses in the same Outlook profile? Using Outlook 1
J How do I send an email from multiple email addresses in Outlook? Using Outlook 3
A Whats the maximun limit of email addresses i can put in the bcc line (Outlook 2003 SP2 with Exch 200 Using Outlook 1
T want to move email contact addresses from outlook express to Outlook Using Outlook 4
T How do you automatically transfer AOL calendar information, like outlook does for aol mail and their addresses Using Outlook 1
S Can't send emails to email addresses on different servers (other than on Outlook 2007 Using Outlook 2
S Outlook cache addresses bounce back after mailbox changes Using Outlook 3
S Outlook 2003: For select messages only, would like replies automatically sent to 2 separate addresses. Using Outlook 4
J Inporting mail addresses from Outlook 2010 into Word 2010 Using Outlook 5
V Outlook auto-populates the email field with sent addresses Using Outlook 1
D Lost Outlook email addresses during System Restore Using Outlook 2
Similar threads