473,326 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Send e-mail of Form

9
I am using Access 2007. I have created a form (WorkRequestForm) and I want to send the information in the form to specific email(s) after clicking the submit button (cmdSubmit). I have a table (tblEmail) with one field (Email) with several entries. I want the email to go to all the emails in the table. I have tried several times to get it to send to the email address in the table and can not resolve it. To make sure the rest of the code was working I created a hidden text box (txtEmail) on the form and that has several email addresses seperated by semi-colon. But I have been told that is not the best way to do it. Here is the code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSubmit_Click()
  2. Dim strBody As String
  3. strBody = "A Work Request has been submitted with the following details:" & _
  4. vbNewLine & " " & _
  5. vbNewLine & "Work Order No:" & " " & Forms!WorkRequestForm!WorkOrderNo & _
  6. vbNewLine & "Request Date:" & " " & Forms!WorkRequestForm!RequestDate & _
  7. vbNewLine & "Requested By:" & " " & Forms!WorkRequestForm!RequestedBY & _
  8. vbNewLine & "Location:" & " " & Forms!WorkRequestForm!Location & _
  9. vbNewLine & "Description of Work:" & " " & Forms!WorkRequestForm!DescriptionOfWork & _
  10. vbNewLine & " " & _
  11. vbNewLine & "Thank You,"
  12. Dim strSubject As String
  13. strSubject = "Work Request Submitted"
  14. DoCmd.SendObject acSendNoObject, Email, acFormatHTML, Forms!WorkRequestForm!Email, , , strSubject, strBody, True
  15. End Sub
Any help would be appreciated.
Nov 8 '13 #1

✓ answered by jimatqsi

SDaxx,
I think this is what you're looking for. Replace line 14 with this. This code creates a recordset mirroring the recordset your form is based on. Then it loops through sending one email to the address of each record in the set.
Jim

Expand|Select|Wrap|Line Numbers
  1. dim rs as dao.recordset
  2. set rs = me.recordsetclone
  3. rs.movefirst
  4. do while not rs.eof
  5. docmd.sendobject acSendNoObject,Email,acFormatHTML,rs!Email, , , strSubject, strBody, True
  6. rs.movenext
  7. loop
  8. rs.close
  9.  

3 3436
jimatqsi
1,271 Expert 1GB
SDaxx,
I think this is what you're looking for. Replace line 14 with this. This code creates a recordset mirroring the recordset your form is based on. Then it loops through sending one email to the address of each record in the set.
Jim

Expand|Select|Wrap|Line Numbers
  1. dim rs as dao.recordset
  2. set rs = me.recordsetclone
  3. rs.movefirst
  4. do while not rs.eof
  5. docmd.sendobject acSendNoObject,Email,acFormatHTML,rs!Email, , , strSubject, strBody, True
  6. rs.movenext
  7. loop
  8. rs.close
  9.  
Nov 9 '13 #2
ADezii
8,834 Expert 8TB
  1. Are you using Microsoft Outlook as your E-Mail Client?
  2. Why not send a Single E-Mail with all Recipients listed in the BCC Field?
Nov 9 '13 #3
SDaxx
9
1. Yes I am using Microsoft outlook.

2. Send a single e-mail to all the e-mails in the table is what I would like to do, but do not know how to do that.

Any help would be appreciated.
Nov 12 '13 #4

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

Similar topics

1
by: Bruce W.1 | last post by:
I'm new to ASP (but not ASP.NET) and I'm trying to setup a simple ASP web form to send an email to me. So I try this code: http://www.library.unr.edu/subjects/guides/mailplay.asp I upload the...
1
by: mhawkins19 | last post by:
I have a form built and on the onclick event I validate all of the fields and then if the form is ok, on the submit event I run a javascript function to set a cookie and download a file from the...
5
by: Abhishek Srivastava | last post by:
Hello All, I wrote the follownig program using System; using System.Web.Mail; public class MailHelper { public static void SendMail(string mailId, string author, string email,
2
by: Eric Peterson | last post by:
I need to pop up the send email form from Outlook. I also need to populate the to field, but obviously the user will type the message and hit 'SEND'. How can I do this? I've been through...
8
by: alice | last post by:
I found this code for making a php email form for a web site. It works fine on my ISP, but not on my friends...could it be that my ISP uses php5, I know that hers does not, so I assume it's php4....
7
Atran
by: Atran | last post by:
Hello, I use Html 4.0 in Dreamweaver program, to send an email, I know that I must put a Form, and I make the Form Action: mailto:MyEmail@hotmail.com Then I put to the Form three textboxes:...
5
by: canajien | last post by:
I have a form that stores information in a table, but I also need it to send an email when a specific question, among the many, is answered with no the question is a simple drop box: <select...
4
by: dfluker | last post by:
This form will not send the email to my account and I used other forms to submit emails using examples that I googled but I can't get this form to process the request. Can someone tell me what i'm...
0
by: Mike Massaro | last post by:
Hello everyone, I'm new to PHP and creating an advertising website for massage therapists. On the profile page I'm creating a button so anyone can click on to send the advertiser an email. I...
1
by: Naqqashrana | last post by:
Sir i am new in php.i am working on forgot password in php. but my send mail function is not working.i have tried many times but all in vain plz help me if it is possible.i have tried according...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.