Results 1 to 3 of 3
  1. #1
    Ravi Kumar is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2019
    Posts
    2

    E-mail criteria

    Dear all,
    I have two columns in my dept heads table ,1 is the location & other is their department head's email id .
    Now in my report I have three columns,1 is location & 2nd is task name , & the other is task due date .
    now i have written a small program to send a mail if any one of the location is set (filtered), using if else.
    but i need a code where it sends a mail to everyone related to the location column say out of 10 location ,i have filtered 4 of them.
    then it should send a mail to all the 4 dept heads related .
    can any one send me the code pls.


  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    make a form with a listbox,
    the list is the groups to mail to

    make a query (for the report) that uses the listbox as a parameter
    select * from table where [group]=forms!myForm!lstbox

    then a button to scan thru the list and email to each.
    The listbox has 2 or 3 columns,
    1 for email addr
    1 for persons name
    1 for key (if needed)

    pull the item the user chose,from the columns you included in the query
    NOTE: IN VB COLUMNS BEGIN WITH ZERO
    so column 1 on the form is column(0) in code.

    Code:
    vRpt = "rMyGrpRpt"
    
    For i = 0 To lstBox.ListCount - 1
      vGrp = listbox.itemData(i)   'get new item
      lstBox = vGrp 
      vName = lstBox .Column(2)
      vTo = lstBox.Column(1)
      VBody = "Dear," & vName & vbcrlf & "Do you like me?"
       DoCmd.SendObject acSendReport, vRpt, acFormatPDF, vTO, , , vSubj, vBody
    next

  3. #3
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Further to ranman's comment/advice, is it people at the location, or people related in some way to the task?
    In effect, what is it that relates department heads, locations and tasks? Why mention tasks if it isn't part of your requirement?
    Your send to list could be as straight forward as Deptheads at same location as X.
    Good luck with your project.

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

Similar Threads

  1. Replies: 1
    Last Post: 09-14-2015, 06:38 AM
  2. Replies: 2
    Last Post: 12-13-2013, 03:13 PM
  3. Replies: 1
    Last Post: 09-14-2012, 10:27 AM
  4. Replies: 5
    Last Post: 08-02-2012, 09:44 AM
  5. Replies: 11
    Last Post: 09-12-2011, 11:30 AM

Tags for this Thread

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