Link to home
Start Free TrialLog in
Avatar of 1212pro
1212proFlag for United States of America

asked on

How can I email users from multiple contact drop down lists on same form

Hello,

Access 2010
I have a form that has multiple dropdown lists (same user contacts in all) that are then displayed on the form as team members for a task.  I would like to send an email notification to those user when they are selected for a task. There is a Save and Close button that is clicked when the form is complete.

Thank you in advance!
1212pro
ASKER CERTIFIED SOLUTION
Avatar of Sheils
Sheils
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 1212pro

ASKER

Hello Sheils,
I'm pretty much a novice at this.  How will outlook know where to look for the email addresses of the team members?  Here are some screen shots of what I have.Team-1.docx
You need a table t store the name and email address of all your contacts.

Let's call that tblContact and it will have the following fields:

fldContactId, fldContactName,fldContactEmail

Then you can use the following code to call the sendemail function

Private Sub Form_AfterUpdate()

Dim strEmailAddress as string
Dim strSubject as String
Dim strBodyText as String

strEmailAddress=DLookup("fldContactEmail","tblContact ","fldContactId=" & Me.cboDelegatedTo)
strSubject ="New Task"
strBodyText ="You have a new text"

Call SendEnail(strEmailAddress,strSubject,strBodyText)

End Sub

Open in new window


This code is just to send email to the person in the delegated to combo. I assume that your combo box is bounded to the id of that person which should come from the contact table.

Once you've got that working and understand how the code works I will help you expand it to also send email to all team members. However, I note that it will be much easier to use a team member table and then use a teammember subform on your main form. In addition to making your code easier it will also give you the flexibility of have bigger teams if necessary.

The tblTeamMember should have the following fields:

fldControlNumber,fldTeamMember (lookup fldContactId in tblContact).