Solved

Access 2007 - sending emails

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

776 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