1212pro
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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,fldContactE mail
Then you can use the following code to call the sendemail function
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,fldTeamMe mber (lookup fldContactId in tblContact).
Let's call that tblContact and it will have the following fields:
fldContactId, fldContactName,fldContactE
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
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,fldTeamMe
ASKER
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