473,548 Members | 2,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Merging Access Contact Info Fields into Outlook VBA

I am trying to use the code below but would like to use an Access table
to feed the 120 individual "email", "subject", "body" and "attachment "
that I need.

What would be the easiest solution to not have to copy this code for my
120 contacts?

Any help greatly appreciated. Thank you in advance.
--------------------------------------------------
On Error GoTo Error_Handler
Dim objOutlook As Outlook.Applica tion
Dim objEmail As Outlook.MailIte m
Set objOutlook = CreateObject("O utlook.applicat ion")
Set objEmail = objOutlook.Crea teItem(olMailIt em)

With objEmail
.To = "Email"
.Subject = "Subject"
.body = "Body"
.Attachments.Ad d "attachment "
.Send
' .ReadReceiptReq uested
End With

Exit_Here:
Set objOutlook = Nothing
Exit Sub
Error_Handler:
MsgBox Err & ": " & Err.Description
Resume Exit_Here
End Sub
-------------------------------------------

Nov 13 '05 #1
2 1702
you need to open a recordset of your recipients from Access
- something like
dim rsRecipients as dao.recordset

set rsRecipients =
dbengine(0)(0). openrecordset(" tblAddresses",d bForwardOnly)

do until rsRecipients.EO F
set objEMail=objOut look.CreateItem (olMailItem)
with objEMail
.To=rsRecipient s("EMailAddress ")
.Subject = "Subject of EMail" '--this is static
.body = strBody
.attachments.ad d(rsRecipients( "SendFileNa me")
.Send
End with
rsRecipients.Mo veNext
Loop

basically, you open the recordset (based on query/table/SQL), and then
you loop through it, pass the data to your mailing function, execute
the .Send method of the message for each recipient in the recordset.

Basically, all you're missing is enclosing your code inside more code
that loops through your recordset of recipients.

With objEmail
'---Modify here from recordset!
.To = rsRecipients("E mailAddress")
.Subject = "Subject" '---this will be the same for everyone
.body = rsRecipients("M essage") '---each recipient will get the
message in the "Message" field of the recipients table
.Attachments.Ad d rsRecipients("F ileToAttach")
.Send
' .ReadReceiptReq uested
End With

Hope that clears things up a little.

Nov 13 '05 #2
Thank you very much, it works perfectly. That was exactly what I needed

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
570
by: Jerry | last post by:
I am trying to create a contact using CDO 1.21. I was wondering if anyone had any sample code of how they may have done this. I am having trouble findinf documentation on how this is done. I would like to avoid useing outlook if possible and write directly to the exchange server if possible. Thanks Jerry.
20
2911
by: wolftor | last post by:
Would anyone be willing to beta test my application for me and give me some feedback? I can give you feedback in exchange (ie. if there are parts you're interested in knowing how it was done) or I can give you a free license if you want to use it. It should install OK but that is part of the problem that needs to be verified on all...
1
4926
by: svdh | last post by:
I have posed a question last saturday and have advanced alot in the meantime. But I am still not there Problem is that I try to merging various fields from various tables in one document in Word 1. Query..I want to keep the fields seperatred. I do not want to sent on field with all accumulated languages from one person to Word. Each...
47
4485
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!
2
5125
by: charliej2001 | last post by:
Hi all Im copying details from an Outlook contact address book into an Access database. Originally I was only copying about 10 fields across, using the the following method, with a line of code for each piece of data being copied TempContactRST.AddNew TempContactRST!FirstName = c.FirstName TempContactRST!LastName = c.LastName
1
4322
by: charliej2001 | last post by:
Hi all My access database has import/export capabiltiy of contact details between outlook. The database is getting big now (1000+ contacts) and so are the outlook address books that have the contacts info in them. When I export contacts from access to outlook, it takes a long time because there are so many contacts in the Outlook address...
1
4571
by: Phil Stanton | last post by:
I have a Yacht Club Db with names addresse phone nos, emails etc. I want to export them to Outlook. No problem in getting them into the contact folder. My problem is I have a folder within the contact folder called "Yacht Club" How do I change the "active folder" from Contacts to "Yacht Club" Existing code here:
5
5342
by: Kosmos | last post by:
I have traveled the world and the seven seas and I have yet to come up with an answer to this question.... So I'm adding an attachment to an email from access... The following is the code: and from here I go to the end (because the other part is in an If statement and that's in a loop...once the loop's finished, I've gathered the...
4
12419
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is this: can Access create the document and place it as an OLE object to the relevant table? Any help is greatly appreciated. Ricky
0
7444
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...
0
7711
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. ...
1
7467
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...
0
7805
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...
0
6039
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...
0
5085
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...
0
3497
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...
0
3478
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1932
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.