Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 6th, 2005, 03:48 PM
Authorized User
 
Join Date: Jun 2004
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here's the code that I use to send out notices from my A2K database. I hope this helps.
==================================================
Public Function EmailNotification()
On Error GoTo Message_Err
    Dim strErrMsg As String 'For Error Handling
    Dim olApp As New Outlook.Application
    Dim olNameSpace As Outlook.NameSpace
    Dim olMail As Outlook.MailItem
    Dim oleMsg As Object
    'Data taken from listbox
    Dim strFileName As String
    Dim strReciprient As String, strResponsibleParty As String 'These are the same person
    Dim strProject As String 'ActionDescription
    Dim strFacility As String
    Dim strFrequency As String
    Dim strDueDate As String
    Dim frm As Form
    Dim sfN As Form 'Program Notification SubForm
    'Gather information to put into body of message
Set frm = Forms!frmMainEntry.Form
Set sfN = frm.[fctlNotifications].Form
    If sfN.[ProgramID] = sfN.[txtID] Then

            strProject = sfN.ProgramDescription
            strFacility = sfN.Facility
            strDueDate = sfN.DueDate
            strFrequency = sfN.FrequencyOfService
            strReciprient = sfN.EmailAddress
            strResponsibleParty = sfN.ResponsibleParty
            strSender = frm!txtWelcome
    Else
        Exit Function
    End If
'Create an email message to send.
Set olNameSpace = olApp.GetNamespace("MAPI")
Set olMail = olApp.CreateItem(olMailItem)

With olMail
    .To = strReciprient
    .BCC = "[email protected]" & "; " & "[email protected]" 'Send a blind copy
    .Subject = "Notification Of Compliance Requirement"
    .Body = vbCrLf & vbCrLf & vbCrLf & _
            "To: " & strResponsibleParty & vbCrLf & vbCrLf & vbCrLf & _
            "This is to notify you that the requirement for " & strProject & " at the " & _
            strFacility & " is due on " & strDueDate & "." & vbCrLf & _
            strProject & " is required " & strFrequency & "." & vbCrLf & vbCrLf & vbCrLf & _
            "Keep On Track With Safety" & vbCrLf & strSender
    .Importance = olImportanceHigh 'High importance
    .ReadReceiptRequested = True
    .Send
End With


Message_Exit:
Set olApp = Nothing
Set olMail = Nothing
Set oleMsg = Nothing
    Exit Function

Message_Err:
    Select Case Err
        Case Else
            strErrMsg = strErrMsg & "Error #: " & Format$(Err.Number) & vbCrLf & vbCrLf
            strErrMsg = strErrMsg & "Error Description: " & Err.Description & vbCrLf
            MsgBox strErrMsg, vbInformation, "Message"
            Resume Message_Exit
    End Select
End Function
==================================================






Similar Threads
Thread Thread Starter Forum Replies Last Post
sending emails for all users in the domain arabuafef ASP.NET 1.0 and 1.1 Basics 6 December 6th, 2006 10:51 AM
Sending automatic emails maitias C# 2005 3 March 3rd, 2006 09:51 PM
Sending emails from smartphone application. unprsandeep C# 0 March 24th, 2005 02:01 PM
sending emails from vb.Net elan22 General .NET 5 May 27th, 2004 08:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.