email button

T

Tony F

Hello all
I am setting up a database of change requests and would like to notify the
approvers, via a command button, whan a new request has been raised.
After the necessary boxes on the "Request Form" have been completed I want
the applicant to "click" a button to send an e-mail to the approvers. Can
anyone tell me how to do this?
The following conditions apply.
I am using Access 2000 & Outlook.
The requests will be serialised, auto number, I need to send only the
current request.
The approvers will be constant.
The body of the e-mail will be a simple message e.g. "please review Change
Request 1234"
 
D

Dorian

Below is sample code. You will need to include the Outlook reference.

' send HTML email
Dim myApp As Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myItem As Outlook.MailItem
Dim myRecipient As Outlook.Recipient

Set myApp = CreateObject("Outlook.Application")
Set myNameSpace = myApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItem = myApp.CreateItem(olMailItem)

myItem.SentOnBehalfOfName = "email of sender"
myItem.Subject = "subject of email"
myItem.BodyFormat = olFormatHTML

' Following Set generates Microsoft email security prompt, must trap NO
response
On Error GoTo EMLER
Set myRecipient = myItem.Recipients.Add("email of receipient")
On Error GoTo 0

Msg = "<body>xxxxxxxxxxxxxxxxxxxxxxxx"
Msg = Msg & "</Body>"
myItem.HTMLBody = Msg
myItem.Display
AppActivate myItem.Subject

Set myRecipient = Nothing
Set myItem = Nothing
Set myFolder = Nothing
Set myNameSpace = Nothing
Set myApp = Nothing

Exit Sub
EMLER:
MsgBox "You chose not to send the email", , "Email aborted"
Exit Sub

-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
T

Tony Toews [MVP]

Tony F said:
I am setting up a database of change requests and would like to notify the
approvers, via a command button, whan a new request has been raised.
After the necessary boxes on the "Request Form" have been completed I want
the applicant to "click" a button to send an e-mail to the approvers. Can
anyone tell me how to do this?

Microsoft Access Email FAQ
http://www.granite.ab.ca/access/email.htm

Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top