Results 1 to 6 of 6
  1. #1
    Fionfion is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Oct 2017
    Posts
    25

    Sending email using values of a combo box(with multiple values)

    Hi all, I have a form which allows users to input the data and send email using the data, everything works well except for when I add a combo box with multiple values and trying to add the values in the email, it won't work - Please help



    My code looks this below (I found it on the internet)

    Code:
    Private Sub sendemail_Click()
    
    On Error GoTo ErrorHandler
    
    
    Dim varName As Variant
    Dim varCC As Variant
    Dim varSubject As Variant
    Dim varBody As Variant
    
    
    varName = "me@gmail.com"
    varCC = "meme@gmail.com, mememe@gmail.org"
    'separate each email by a ','
    
    
    varSubject = "My email subject"
    'Email subject
    
    
    varBody = "My email body"       'Im trying to add a combo box with multiple values here
    
    
    
    
    'Body of the email
    DoCmd.SendObject , , , varName, varCC, , varSubject, varBody, True, False
    'Send email command. The True after "varBody" allows user to edit email before sending.
    'The False at the end will not send it as a Template File
    
    
    ErrorHandler:
        Select Case Err.Number
        Case 2501
        MsgBox ("Email not sent.")
        End Select
    
    
    End Sub

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Perhaps this link will help: http://www.granite.ab.ca/access/email.htm

    It's my favorite email link.

  3. #3
    knarfreppep is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Feb 2015
    Location
    Adelaide, Australia
    Posts
    106

    Arrow

    List Box not Combo Box


    For Each varListItem In ListBox.ItemsSelected
    varBody = varBody & vbCRLF & varListItem
    Next

  4. #4
    Fionfion is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Oct 2017
    Posts
    25
    Thank you so much for your code!!!

    The code you provided only returns the row number (Or I did something wrong), but based on your code I found a way to return the values of the row - below is my code:

    Code:
    For Each varListItem In ListBox.ItemsSelected
    
    varBody = ListBox.Column(varListItem) 
    Next varListItem 
    Thank you again for your help!!

  5. #5
    Fionfion is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Oct 2017
    Posts
    25
    Quote Originally Posted by RuralGuy View Post
    Perhaps this link will help: http://www.granite.ab.ca/access/email.htm

    It's my favorite email link.
    Thanks for your help too, just that it seems very complicated (I'm new to Access & don't know much about programming) Thank you!!

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Your most welcome. Just bookmark the site for the future.

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

Similar Threads

  1. Replies: 3
    Last Post: 10-30-2016, 05:50 AM
  2. Saving multiple values in look-up combo box
    By AnnSparks in forum Database Design
    Replies: 5
    Last Post: 01-23-2015, 02:18 PM
  3. Multiple Combo box - duplicating values
    By Haleakala17 in forum Forms
    Replies: 2
    Last Post: 09-18-2012, 06:26 PM
  4. Replies: 1
    Last Post: 03-27-2010, 06:13 AM
  5. Replies: 0
    Last Post: 12-19-2006, 09:44 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