Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Email Daily Thank You
Brent Davis 
     
8 months ago
Help. I have my DB set up to email customers daily based off my call list for the day. It works well. Currently I can only email one customer contact per customer email. I have my call Info form set up to where I can have two contacts listed for each call if needed. In the thank you email I would like both individuals to receive the email at their own email address. In my contacts(people) form, the fields are ContactID, ContactName, ContactTitle, ContactEmail, etc. In my CALL info form I have a field for OtherContactID. This field is a combo box(OtherContactCombo) on my callinformationform which also has a combo box(ContactCombo) for the contactid. Currently, the customer in the contactID field populates in both the To and CC field when the sendemail code runs. Here is my code:

DetailsPrivate Sub SalesEmailBTN_Click()

    Dim db As Database
    Dim rs As Recordset
    Dim Counter As Long
    Dim Greeting As String
    Dim LastNote As String
    Dim Currenthour As Long
    Dim ID As Long
    Dim Msg As String, Subject As String, Signature As String, CCEmail As String
    
    If MsgBox("Are you SURE?", vbYesNoCancel) <> vbYes Then Exit Sub
    
    Currenthour = Hour(Now)
    
    Select Case Currenthour
        Case 0 To 11
            Greeting = "Good Morning"
            LastNote = "morning"
        Case 12 To 16
            Greeting = "Good Afternoon"
            LastNote = "afternoon"
        Case Else
            Greeting = "Good Evening"
            LastNote = "evening"
    End Select
    
    
    Set db = CurrentDb
    Set rs = db.OpenRecordset("Select * From SendDailyCustomerEmailQ")
    Counter = 0
    While Not rs.EOF
    
        
    If rs!SalesCallTypeID = 2 Then
    
        Msg = Greeting & " " & rs!Contacted2 & ",

" & _
        "Thank you for taking the time to speak with me today. It was a pleasure spending some time with you. Please visit our website, www.sefl.com, for more information about how we can assist with your transportation needs." & "

" & _
        "If you have any questions or I can assist in any way, please let me know. " & "

" & _
        "Have a fantastic" & " " & LastNote & "! "
            Subject = "Thank you!"
            
    
            
       ElseIf rs!SalesCallTypeID = 3 Then
      
    
        Msg = Greeting & " " & rs!Contacted2 & ",

" & _
        "Thank you for taking the time to speak with me today. It was a pleasure spending some time with you. If you have any questions or I can assist in any way, please let me know." & "

" & _
        "Have a fantastic" & " " & LastNote & "! "
            Subject = "Thank you!"
            
                
        ElseIf rs!SalesCallTypeID = 5 Then
        
        Msg = Greeting & " " & rs!Contacted2 & ",

" & _
        "Thank you for taking the time to speak with me today about our sister company eShipping Exchange. It was a pleasure spending some time with you. If you have any questions, you can visit the eShipping website at www.eshippingexchange.com, or reach out to me at the contact information below." & "

" & _
        "Thank you for the opportunity to assist with your transportation needs! " & "

" & "Have a fantastic" & " " & LastNote & "! "
            Subject = "Thank you!"
            
                            
    End If
    
    ID = Nz(DLookup("OtherContactID", "SendDailyCustomerEmailQ"), 0)
    
    If ID <> 0 Then
        CCEmail = rs![Contact Email] ' I want the email associated with this ID to populate the CCEmail but currently it is the same as the To: contact email even though the ID is for the OtherContactID. I was hoping it would see the ID and grab the email in the contacts table for that ID.
        
    MsgBox ID 'this ID pulls correctly as the OtherContactID
    
    End If
    
    SendEmail Msg, Subject, rs![Contact Email], Signature, rs![Contact Email], False
    rs.Edit
    rs!sentemail = True
    rs.Update
    
    Counter = Counter + 1

        rs.MoveNext
    Wend
    Set rs = Nothing
    Set db = Nothing
    
    MsgBox " Done! Sent " & Counter & " emails."
    
End Sub


I know the problem is in this code: SendEmail Msg, Subject, rs![Contact Email], Signature, rs![Contact Email], False

But how do I specify the email that coordinates with the OtherContactID in the CCEmail location which is the second rs![Contact Email]?

This may not make since but any assistance is appreciated. Thanks.
Richard Rost  @Reply  
          
8 months ago
If there's only one, what you could do is after you send it to the primary person, you could do a DLookup and look up that other contact information and then issue a second send email. I'd have to see your table structures to tell you for sure what's going on there, but you could do it with a union query, you could do it with a DLookup, or you could do it with another recordset. There's a million ways to do it, but I don't have enough information based on what you gave me to give you a definite answer.
Raymond Spornhauer  @Reply  
          
8 months ago
Add the second email address to your: SendDailyCustomerEmailQ

You'll have to give it a name since the field is a duplicate.

Then you can reference this field with your recordset.

-Raymond
Kevin Robertson  @Reply  
          
8 months ago
Why are you using a DLookup when you are in a Recordset?
It is always going to return the first record.
Richard Rost  @Reply  
          
8 months ago
Kevin is correct. The way that you've got that DLookup structured, it's just going to pull up the same record. It's going to actually pull up the first record of the table for every single loop of your record set. You need to pull up the specific contact email address for that person in the record set loop's record. So you need some criteria on that. You have none right now.
Brent Davis OP  @Reply  
     
8 months ago
Gentlemen, I am by no means fluent in any of this. This DB is just for me, I am not a developer but  I am trying to learn new things. I am trying to build this with the structure of the tables I have in place. I probably need to overhaul some things but was just throwing things on the wall to see if anything would stick. As I  learn, or see something I wish to learn, I start experimenting. Thus, I am here, over my head asking for a life preserver. Here are my tables & Query:

ContactT
  ContactID
   Contact name
   ContactTitle
   Contact Email

Call Info
    CallInfoID
     ContactID (combo box on form)
     OtherContactID (combo box on form)
      CallDate
      Notes

Form fields
      CallDate, ContactID(combo box), Contact Title, Contact Email, Notes


   SendDailyCustomerEmailQ
          ContactID, SalesCallTypeID, Call Date, Contact Email,  OtherContactID

As always, any guidance is appreciated!






Brent Davis OP  @Reply  
     
8 months ago
SalescalltypeID is on the call info table. I mistakenly left it off on the above post
Richard Rost  @Reply  
          
8 months ago
OK, since you already have OtherContactID in your query, you should be able to get that person's info using a SELF JOIN query. It's a little difficult to explain here. I'll try to cover this in this week's Quick Queries video for you which I'll be recording tomorrow. In the mean time, watch this: Self Join Relationships
Brent Davis OP  @Reply  
     
8 months ago
Richard - with your self join relationship info and an assist from ChatGPT, I was able to make it work!!  Thanks so much for your assistance!
Richard Rost  @Reply  
          
8 months ago
Yeah, well I've still got you slated for the next Quick Queries video, so whether you like it or not, I'm gonna mention it LOL.
Brent Davis OP  @Reply  
     
8 months ago
Mention away!!  I love this stuff and this community!  I am making progress. Now I know just enough to be dangerous!!
Brent Davis OP  @Reply  
     
8 months ago
Just wanted to say thanks for everyone’s help on this one. I learned so much going through this problem. I would solve one thing and then something else would pop up and so on and so on.  Then new ideas would arise and I would play with it some more. All just to send a couple of emails with an option for different salutations based on time of day, possible multiple names and closings. But it sure was cool when it worked! Richard, I know why you say learn SQL, because it is so much easier to make changes even though I struggled with it. But through the process, things started to make more sense. I know what I want most times and what I want it to look like but I sometimes can’t see the programming concept to it yet. I miss a lot of the little fundamentals. But, I think I have it the way I want it now but who knows!  I will watch a Tech Help video and down the rabbit hole I will go again!  What I do know, you are a fantastic teacher and this community is wonderful! You have created an awesome place to learn and I am excited to see what you have in store for us next! Have a splendid evening all.
Richard Rost  @Reply  
          
8 months ago
Your success is exactly why I do what I do. :)

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 4/30/2026 6:53:49 PM. PLT: 1s