Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

Excel Template: Automatically send an e-mail for a specific entry in Excel

05.09.2018 (👁4456)


 

The following Excel document automatically sends an email when a specific value is entered in an input area.

If a value such as Test ... is entered in the input column B: B, then a standard email is automatically sent via Outlook.

You can customize the Excel file by adjusting the settings in Excel with Alt-F11 in the vba macro code page.

 

Vba code

Necessary vba macro code in excel

Under Alt-F11 in the Excel Document

The address and the text can be set in the header area

'-----< Setup >------

Private Const °Input_Check As String = "Test*"

 

Private Const °Email_Address_To As String = "raimund.popp@codedocu.de"

Private Const °Email_Title As String = "Test Automatische Email bei Excel-Eingabe"

Private Const °Email_Text As String = "This is Email-Text"

'-----</ Setup >------

 

 

 

Option Explicit On

 

'-----< Setup >------

Private Const °Input_Check As String = "Test*"

 

Private Const °Email_Address_To As String = "raimund.popp@codedocu.de"

Private Const °Email_Title As String = "Test Automatische Email bei Excel-Eingabe"

Private Const °Email_Text As String = "This is Email-Text"

'-----</ Setup >------

 

 

'==================< Events >==================

Private Sub Worksheet_Change(ByVal Target As Range)

    '--------< Worksheet_Change(ImputCell) >--------

    '*After_Cell_Input_Change

    If Not Intersect(Target, Range("B:B")) Is Nothing Then

        If Target.Value Like °Input_Check Then

            Dim sText As String

            sText = °Email_Text

            sText = sText & vbCrLf & "Eingabewert =" & Target.Value & " in Zeile: " & Target.Address

            Send_Email(sText)

        End If

    End If

    '--------</ Worksheet_Change(ImputCell) >--------

End Sub

'==================</ Events >==================

 

 

 

'==================< Functions >==================

Private Sub Send_Email(ByVal sText As String)

    '-------------< Send_Email() >-------------

    '----< Send with Outlook >----

    Dim app_Outlook As Outlook.Application

    Set app_Outlook = New Outlook.Application

   

    '--< Email einstellen >--

    Dim objEmail As Outlook.MailItem

    

    '--< Send Email >--

    Set objEmail = app_Outlook.CreateItem(olMailItem)

    objEmail.To = °Email_Address_To

    objEmail.Subject = °Email_Title

    objEmail.Body = sText

    objEmail.Display False

    objEmail.Send   '*optional

    '--</ Send Email >--

        

    

    '< Abschluss >

    Set objEmail = Nothing

    Set app_Outlook = Nothing

    '</ Abschluss >

        

    '----</ Send with Outlook >----

    '-------------</ Send_Email() >-------------

End Sub

 

'==================</ Functions >==================