Results 1 to 2 of 2
  1. #1
    jj1 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    128

    Automatic email not sent to the names with a middle name


    I am using the code below as discussed previously. I have another problem. My table "Employee" in the recognition database has employee information. It has a field for employee "name". Large number of people have names with middle name. Email works fine for people with just first and last name. Code is not able search the middle name as it does not exist in our company outlook. Code is doing its work. I don't want to delete the middle names from the database to match outlook. Is it possible to make modification in the code so that code just search for only first and last name not middle name. Below is the

    Code:
    Private Sub Label140_Click()
    On Error Resume Next
    Dim Combo97  As String
    Dim stText96 As String
    
    
    
    
    If IsNull(Me![Combo97]) Then
        MsgBox "You must read the Recognition.", vbOKOnly, "More Data Required!"
        Exit Sub
    End If
    
    
    RunCommand acCmdSaveRecord
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    Me.Refresh
    Me.Dirty = False
    DoCmd.SetWarnings False
    Dim oApp As Outlook.Application
    Dim oMail As MailItem
    Set oApp = CreateObject("Outlook.application")
    
    
    Set oMail = oApp.CreateItem(olMailItem)
    
    
     stText96 = Format(Me.Text96, "00000")
     
    oMail.HTMLBody = "A Recognition has been submitted for you in the Recognition database. Please address this Recognition.." & Chr$(13) & _
                   Chr$(13) & "Recognition Number: " & stText96 & Chr$(13) & "" & Chr$(13) & _
                   Chr$(13) & "Below is the link to the database... " & Chr$(13) & _
                   Chr$(13) & "<a href=""" & "C:\Recognition - Front End.mde" & """>" & "C:\Recognition- Front End.mde" & "</a > " & Chr$(13) & _
                   Chr$(13) & "***THIS IS A SYSTEM GENERATED EMAIL. PLEASE DO NOT REPLY TO THIS EMAIL****."
     
    oMail.Subject = "You have received a new Recognition."
    oMail.To = Forms![New Recognition]!Combo97
    oMail.CC = ""
    oMail.Send
    Set oMail = Nothing
    Set oApp = Nothing
    
    
    DoCmd.GoToRecord , , acNewRec
    DoCmd.SetWarnings True
    'DoCmd.Close acForm, NewRecognition, acSaveYes
    'Exit_addNewRecord_Click:
    '    Exit Sub
    'Err_addNewRecord_Click:
    '    MsgBox Err.Description
    '    Resume Exit_addNewRecord_Click
    
     End Sub

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Please indicate what a string in Combo97 looks like, what the source for Combo97 is, and what the expected match in Outlook looks like. We can't fix your code if we don't know what data it is working with.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Send automatic email with form
    By matirob in forum Forms
    Replies: 1
    Last Post: 03-19-2016, 09:07 AM
  2. Replies: 9
    Last Post: 01-08-2015, 12:34 PM
  3. Automatic Email
    By Peacekeeper in forum Access
    Replies: 8
    Last Post: 11-03-2011, 10:55 AM
  4. Replies: 3
    Last Post: 05-08-2011, 12:55 PM
  5. Changing color in middle of email message
    By tgavin in forum Programming
    Replies: 5
    Last Post: 11-30-2010, 01:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums