By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,291 Members | 1,613 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,291 IT Pros & Developers. It's quick & easy.

Auto email

P: 1
I am in the process of developing an Ideas management database for the company which I work for.

I require an email facility driven by a Submit button from a form on Access, my problem is the email needs to be directed to the departmental manager selected on the form.

Managers details are stored in a table called Departments with following fields
Department - Manager - Email

Also a copy of the email needs to be sent to myself (Scheme Administrator)

I have made several attempts at trying to achieve the above but have been unsuccessful.

I look forward to hearing a solution

Many thanks

John
Oct 9 '08 #1
Share this Question
Share on Google+
1 Reply


P: 90
I'm not entirely sure this is what you mean, but this works for me.
Replace 'you@youremail.com' with your email address, if you want to BCC instead of CC it, then move it to the next space (between the next , ,)

Expand|Select|Wrap|Line Numbers
  1. Private Sub SubmitButton_Click()
  2. On Error GoTo SubmitButton_Err
  3.  
  4. Email= DLookup("[email]", "Departments", "[Department] =Forms![FormName]![Dept]"
  5.  
  6.     If IsNull(Email) = False Then
  7.         DoCmd.SendObject , , , Email,"you@youremail.com" , , "Email Subject", "Email Body", True
  8.     Else: MsgBox "Are you sure there's an email address for this manager?.", vbInformation, "Check Email Address"
  9.     End If
  10.  
  11. SubmitButton_Exit:
  12.     Exit Sub
  13. SubmitButton_Err:
  14.     MsgBox Error$
  15.     Resume SubmitButton_Exit
  16. End Sub
Assumptions:
  • A textbox called 'Dept' on form contains the value of 'Department' from the table 'Departments'
  • The button is called SubmitButton
If you want to lookup the Manager too; make another DLookup with 'Manager' instead of Email.
Oct 9 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.