Send an email...

S

socka

How would i send an email through outlook......from an access data project (adp) file
 
K

KD

1. In the Access VBA Editor (Alt-F11), select "Tools - References", then
check "Microsoft Outlook 9.0 Object Library".
2. Create the following procedure in a code module

Sub SendOutlookMail()
Dim objOL As Outlook.Application
Set objOL = CreateObject("Outlook.Application")

Dim msg As Outlook.MailItem
Set msg = objOL.CreateItem(olMailItem)

With msg
.To = "[email protected]"
.Subject = "Test"
.Body = "This is my message"
.Save
'Take a look at the saved message in your "Draft" folder first,
'to make sure all's well before uncommenting the next line
'.Send
End With

Set objOL = Nothing
Set msg = Nothing
End Sub

Hope this helps,
Klaus
 
Top