Solved

Access 2007 - sending emails

Posted on 2011-02-20
5
364 Views
Last Modified: 2012-05-11
My OS is windows 7 and I have a small database with email addresses.  I want to automate the process of sending a message from Access or using mail merge from MS word.  Is there any sample apps or template that I can follow.  I propose to use Outlook as my email client.  Thank u.
0
Comment
Question by:jegajothy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 15

Accepted Solution

by:
gplana earned 167 total points
ID: 34938923
Please try this:
Option Compare Database
Option Explicit


Public Function SendMail(DisplayMsg As Boolean, strTo As String, strCC As
String, strBCC As String, _
strSubject As String, strBody As String, strAttachPathFile As String) As
Boolean

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment

Set objOutlook = CreateObject("Outlook Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)


With objOutlookMsg

'Add "To" recipient
Set objOutlookRecip = .Recipients.Add(strTo)
objOutlookRecip.Type = olTo

'"Add "CC" recipient
If IsNull(strCC) = False Then
Set objOutlookRecip = .Recipients.Add(strCC)
objOutlookRecip.Type = olCC
End If

'Add "BCC" recipient
If IsNull(strBCC) = False Then
Set objOutlookRecip = .Recipients.Add(strBCC)
objOutlookRecip.Type = olBCC
End If

'Add subject, body, and importance of the E-Mail Messzage
.Subject = strSubject
.Body = strBody
.Importance = olImportanceHigh


'Add Attachment
If IsNull(strAttachPathFile) = False Then
Set objOutlookAttach = .Attachments.Add(strAttachPathFile)
End If

For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next objOutlookRecip

.Send
End With

Set objOutlookMsg = Nothing
Set objOutlook = Nothing


End Function

Open in new window

0
 
LVL 19

Assisted Solution

by:Richard Daneke
Richard Daneke earned 167 total points
ID: 34938985
You can use Word 2007 or Publisher 2007  to send customized emails to a list of recipients that may (or may not ) be in your Contacts list.  Outlook is the program that sends the emails.

In this case, you use Access to maintain the list of intended recipients.   Update Access tables with names, email addresses and other data fields for the email.

For Word or Publisher, create a file and use Mailings tab to start send emails.  The recipient list can use an Access table, an Access query, or Outlook Contacts to send email.

The VBA code example is great for sending email from within an Access database.  
0
 
LVL 92

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 166 total points
ID: 34939152
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 34966603
jegajothy,

Glad to help!  If you have not already done so, I would really appreciate it if you could please return to my article
http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/A_4316-Automate-Outlook-in-VBA-with-the-OutlookCreateItem-Class.html
and click 'Yes' for the 'Was this helpful?' voting.

Patrick
0
 

Author Comment

by:jegajothy
ID: 34966794
Patrick,
I saw your article, since my present project is a volunteer one, thus I would not want to spend too much time on it.  But it is good to know that it is doable especially when we have Gurus like u.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question