Free Code Snippets in C#, Net Framework, Office 365, ASP.Net,WPF, Visual Studio, SQL Server, Antivirus free


Datei 1: 2017-10-10_Email_senden.accdb



Included as Outlook.

Code example in vba Programming


You can send emails directly into Microsoft Access databases.

All you need is an e-mail address, an e-mail subject and an e-mail.


For this, it is recommended to use Outlook as the default email program. You can send the emails as plain text or as HTML, and even attach PDF documents automatically, like for example invoices.



A small example is attached here for testing.


If you click the Send Email button, the email will automatically be sent from your own email account to the desired address.



Vba macro code to insert into your own data program and Microsoft MsAccess

Option Compare Database

Option Explicit On


Private Sub btnSend_Click()


End Sub




Private Sub fx_Email_Senden()

    '-------------< fx_Email_Senden() >-------------


    Dim sEmail_Adress As String

    sEmail_Adress = ctlEmail_Address.Value


    Dim sTitle As String

    sTitle = ctlTitle.Value


    Dim sText As String

    sText = ctlText.Value


    '----< USE OUTLOOK APP >----

    Dim app_Outlook As Outlook.Application

    Set app_Outlook = New Outlook.Application


    '--< Email einstellen >--

    Dim objEmail As Outlook.MailItem

    Set objEmail = app_Outlook.CreateItem(olMailItem)

    objEmail.To = sEmail_Adress

    objEmail.Subject = sTitle


    objEmail.HTMLBody = sText

    objEmail.Display False



    '--< Email einstellen >--


    '< Abschluss >

    Set objEmail = Nothing

    Set app_Outlook = Nothing

    '</ Abschluss >


    '----</ USE OUTLOOK APP >----

    '-------------</ fx_Email_Senden() >-------------

End Sub






If you send an email and a message from Microsoft Outlook appears before sending it, that is due to the security settings in Microsoft Outlook.

In the standard, the e-mail should be sent without an intermediate message.



The following email Outlook file-> TrustCenter settings are set:

Under Outlook Options in the Trust Center

If macro settings are set to Notification for digitally signed macros, and add-ins are turned off.

Access: Sending emails directly from the database


Contact for Jobs, Project Requests: