473,398 Members | 2,113 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,398 software developers and data experts.

sending e-mail using VBA from a button on an Access Form

1
Hi,

I need to know how I can send all of the e-mail address's from clicking on a button that I put on a form in Access to a default e-mail on a computer. This is what I want to be able to do I create a form that has a button on it and when it is click it pulls all of the e-mail address's from my query and puts them into the default e-mail I have on my computer. So that I can e-mail all of the people with out having to type each e-mail address in from my query results. I am using Access 2003 Any help anyone can give would be greatly appreciate thanks in advance for your help.

~Dana
Oct 16 '06 #1
2 8257
MMcCarthy
14,534 Expert Mod 8TB
Try something like this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private sub CommandBtn_Click()
  3.  
  4.     sendEmail("Subject text", "Message text")
  5.  
  6. End Sub
  7.  
  8.  
Put the following function in a module

Expand|Select|Wrap|Line Numbers
  1.  
  2. Function sendEmail(subText As String, message As String)
  3. ' function to send an email 
  4. Dim db As Database
  5. Dim rs As Recordset
  6. Dim mailList As String
  7.  
  8.     Set db = CurrentDb
  9.     Set rs = db.OpenRecordset("SELECT email FROM TableName")
  10.  
  11.     mailList = ""
  12.     rs.MoveFirst
  13.     Do Until rs.EOF
  14.         mailList = mailList & rs!email & ";"
  15.         rs.MoveNext
  16.     Loop
  17.  
  18.     ' send the email
  19.     DoCmd.SendObject acSendNoObject, , , mailList, , , subText, message, False
  20.  
  21.     rs.Close
  22.     Set rs = Nothing
  23.     Set db = Nothing
  24.  
  25. End Function
  26.  
  27.  
Hi,

I need to know how I can send all of the e-mail address's from clicking on a button that I put on a form in Access to a default e-mail on a computer. This is what I want to be able to do I create a form that has a button on it and when it is click it pulls all of the e-mail address's from my query and puts them into the default e-mail I have on my computer. So that I can e-mail all of the people with out having to type each e-mail address in from my query results. I am using Access 2003 Any help anyone can give would be greatly appreciate thanks in advance for your help.

~Dana
Oct 16 '06 #2
This is the first time i 've tried to use Access and I am not familiar with VB.
I am trying to perform a similar functiona as Donna wanted to do. I wanted to send e-mail automatically to a group of receipts when I open a form.

1. I have put the sendEmail function in a new model and named it testemailmodel.
2. I have created a table to hold all the e-mail address
3. Could you please guide me through how I can put the sendEmail("Subject text", "Message text") code correct so that when I open a form, it automatically send the e-mails.

Also, I found that I can build a macro by select sendopen object and select the query to send the query result to the receipt. my question is:
1. how can I bypass the confirmation message before the marcro send the e-mail?
2. Is there a way to attach 2 query results in one e-mail?

Thank you very much for your help!
Feb 15 '07 #3

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

Similar topics

3
by: Paul Lamonby | last post by:
Hi, I am sending a file from the server as an email attachment. The file is being attached no problem and sending the email, but I get an error when I try to open it saying it is corrupt....
2
by: John Abel | last post by:
I have written a script that makes a telnet connection, runs various commands, and returns the output. That was the easy bit :) However, to close the session, I need to send ^] followed by quit. ...
4
by: Winston Nimchan | last post by:
Hi: I'm currently developing a socket application and would like to precede the data being sent with a 4 byte message length header (bin4). Can anyone help Regards Winston
7
by: Lau | last post by:
I need to send 1000 emails from an asp.net website. Normally I would use System.Web.Mail.MailMessage() to send thru an SMTP server. But the large amount of emails results in a timeout. My server...
3
by: Sydney | last post by:
Hi, I am trying to construct a WSE 2.0 security SOAP request in VBScript on an HTML page to send off to a webservice. I think I've almost got it but I'm having an issue generating the nonce...
3
by: Juergen | last post by:
hi, I've got a problem sending floating point values to an corba server. With other datatyes like short or string it works fine. So having this idl file : module Example{ interface User{
8
by: Amol | last post by:
Hi , I am developing a web application.I need an interface in my application which will allow the user to send the fax domestic /international.I dont want to use 3rd party tool /service .Does...
0
by: Vajrala Narendra | last post by:
in the i got few problems please solve to help me also send information regarding email sending. Try Dim mailbody As String mailbody = "" mailbody =...
5
by: hurricane_number_one | last post by:
I am creating a simple server application, that will listen for incoming mouse coordinates and then move the mouse accordingly. So basically it's like a very simple VNC server without and screen...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.