Home  Fees/Services  Microsoft Access Templates  Tutorials  Access Download  Articles  Search  Contact  Privacy  Links

Access VBA Tutorial
   
Access Programming Examples & Code Samples

Send Outlook Email From Access Visual Basic Tutorials, Workarounds & Solutions for VB6
Send Email from Access to Outlook




VBA Tutorials:
Access to Google Earth
VB6 Age Calculation
Change Case VBA
VBA Email via Gmail
VBA Outlook Email
Read Email Access
RTF Report Email
Send Outlook Email Access
Calculate Running Sum
Concatenate Records
VBA Stock Quotes
VBA CreateQueryDef
Database Path Solution
Detail-Master Update
Field Validation VBA
Field Value New-Old
FindFirst Recordset
Get Version Number
VB6 Global Parameters
VBA Global Variables
Labels as Links
List Box Files List
VBA Mail Merge
OutputTo Crosstab
Sort Recordset Trick
VBA Recordset Filters
Reference Form Field
VBA Select Case
Transaction Processing

Visual Basic Function Examples


Send Outlook Email From Access VBA

Send Outlook Email from Access: Communication between Access Forms and Outlook is a fairly simple task once the initial code is debugged.

You can also send multiple messages using the CC function or looping through a record set and sending each email individually.

There are 3 examples of sending emails between Access database and Outlook API on our website:

Below is our main screen for managing  email communication with business contacts in our Contact Management Database.

New! Download Access example of  Send Email to Outlook

Note that on the form the three fields in the upper right - one for email subject, another for the email body and 3rd field for an email attachment.
 


When the user presses the Produce Output button the following code is activated:

Private Sub Email_Output_Click()
'
' Email API Outlook example programming code
' Send email from to Outlook
'

Select Case Me.Email_Output_Option
    Case 1
        Dim mess_body As String
        Dim rst As DAO.Recordset
        Dim appOutLook As Outlook.Application
        Dim MailOutLook As Outlook.MailItem
        Set appOutLook = CreateObject("Outlook.Application")
        Set MailOutLook = appOutLook.CreateItem(olMailItem)
        Set rst = Form_F_People_Mailings.RecordsetClone
        rst.MoveFirst
        Do While Not rst.EOF
            If IsNull(rst!Email) Then
                MsgBox "skipping " & _
                Form_F_People_Mailings.LastName & _
                " no email address."
                GoTo skip_email
            End If
            mess_body = "Dear " & rst!Salutation & " " & _
            rst!LastName & "," & _
            vbCrLf & vbCrLf & Me.Mess_Text
            Set appOutLook = CreateObject("Outlook.Application")
            Set MailOutLook = appOutLook.CreateItem(olMailItem)
            With MailOutLook
                .To = rst!Email
                    .Subject = Me.Mess_Subject
                    .Body = mess_body
                    If Left(Me.Mail_Attachment_Path, 1) <> "<" Then
                        .Attachments.Add (Me.Mail_Attachment_Path)
                    End If
                    'next line would let MS Outlook API send the note
                    'without storing it in your sent bin
                    '.DeleteAfterSubmit = True

                    .Send
                End With
skip_email:
        rst.MoveNext
    Loop
    rst.Close
    Set rst = Nothing
Case 2

---------------------------------------------------------------

When the first email gets sent from Access to MS Outlook you'll get a popup security message asking if you want to send the email message and you can have the connection open for a variable amount of time.  You can download a program, I believe it is called ClickYes that will send the OK button click automatically so you won't have to do it manually for each email.  See our example on how to read email into Access.

***NEW*** Download a working example of Sending Email to MS Outlook.








Have errors?  No doubt we can answer your question quickly and easily.  Simple questions get simple answers at no charge via email.




Popular Database Templates:

Personnel Agency Access Template Database

Rx/Prescription Assistance Plan Admin Template

Subscription Order Control Database Template




Contact Information

VBA runtime tips tricks fix solution

Access Visual Basic/VBA/VBScript/VB6 Tutorials
Visual Basic Error Fix & Problem Solutions