You are on page 1of 3

Sending an Email from MS Access No third

party dll allowed

I need to send a series of email notifications from an MS Access


Database.

No third party dll's like Redemption

Cannot trip the outlook security warnings

The email will have a pdf attachment

I know to do this I need to use MAPI, but I can't seem to find a way to
do this with VBA.
up vote 3 down vote Any help would be appreciated
favorite
Thanks,
Scott
ms-access vba outlook
edited Aug 7 '09 at asked Jul 16 '09 at
21:22 14:06
shareimprove this
question
Fionnuala Scott
76.9k665110 925
add a comment

3 Answers
active oldest votes
up vote
2 down If you can live with requiring CDO to be present on the machine, and you don't
vote
mind a user-provided SMTP server, you can use that. Just google for some example
accepted code, but for you convenience I'll paste some below from www.rondebruin.nl :

Sub
Dim
Dim
Dim
'

CDO_Mail_Small_Text()
iMsg As Object
iConf As Object
strbody As String
Dim Flds As Variant

Set iMsg = CreateObject("CDO.Message")


Set iConf = CreateObject("CDO.Configuration")
'
iConf.Load -1
' CDO Source Defaults
'
Set Flds = iConf.Fields
'
With Flds
'
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") =
2
'
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")
_
'
= "Fill in your SMTP server here"
'
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverpor
t") = 25
'
.Update
'
End With
strbody = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2" & vbNewLine & _
"This is line 3" & vbNewLine & _
"This is line 4"
With iMsg
Set .Configuration = iConf
.To = "ron@debruin.nl"
.CC = ""
.BCC = ""
.From = """Ron"" <ron@something.nl>"
.Subject = "Important message"
.TextBody = strbody
.Send
End With
End Sub

Adding an attachment would be done using .AddAttachment "C:\files\filename.pdf"


on the iMsg.
answered Jul 16 '09 at 18:32
shareimprove this answer
Paul-Jan
11.2k3165
I was toying with this idea to start with, it is the way I decided to go --Thanks
Scott Jul 17 '09 at 12:45
This also helped....Item
("schemas.microsoft.com/cdo/configuration/smtpusessl") = true Praesagus

Sep 20 '11 at 16:01


add a comment

If the user has outlook installed:


Dim
Dim
Dim
Dim
Dim
Dim

strErrMsg As String 'For Error Handling


olApp As New Outlook.Application
olNameSpace As Outlook.NameSpace
olMail As Outlook.MailItem
oleGrf As Object
strFileName As String

Set olNameSpace = olApp.GetNamespace("MAPI")


Set olMail = olApp.CreateItem(olMailItem)
Set oleGrf = Me.OLEchart.Object
strFileName = "c:\temp\Graph.jpg"
oleGrf.Export FileName:=strFileName

up vote 0 With olMail


.To = "someone@somewhere.com"
down
.Subject = "Graph Info " & Format(Now(), "dd mmm yyyy
vote
.Attachments.Add strFileName

hh:mm")

.ReadReceiptRequested = False
.Send
End With
Kill strFileName

Also check out Tony Toews's Microsoft Access Email FAQ


answered Jul 16 '09 at 14:10
shareimprove this answer

edited Jul 17 '09 at 0:50

Mitch Wheat
214k28345442
Which is a great resource, but contains no actual answer to the question.
Although I must say I don't think an answer satisfying all posed retrictions
exists. Paul-Jan Jul 16 '09 at 18:23
add a comment
See the page Microsoft Access Email FAQ - Directly via the Winsock I haven't
up vote 0
tried those myself but you should be able to adapt the VB6 code to send the emails
down vote
directly.