Solved

Access 2007 - sending emails

Posted on 2011-02-20
5
359 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
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 18

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now