473,545 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to send email to predetermined address in Access?

9 New Member
I've created a form for use by our employees. I have it simple as possible with a New Record, Save Record, and Email command buttons.

The email command is set up to mail a specific query that I have created. Everything works properly, but when you click to email a command pops up to select my format, and then opens microsoft office to have me type in the email addresses.

Expand|Select|Wrap|Line Numbers
  1. Private Sub MAIL_Click()
  2. On Error GoTo Err_MAIL_Click
  3.  
  4.     Dim stDocName As String
  5.  
  6.     stDocName = "PURCHASE ORDER Query"
  7.     DoCmd.SendObject acReport, stDocName
  8.  
  9. Exit_MAIL_Click:
  10.     Exit Sub
  11.  
  12. Err_MAIL_Click:
  13.     MsgBox Err.Description
  14.     Resume Exit_MAIL_Click
  15.  
  16. End Sub

That is the default code for email. What needs to be done so that when I click the email command it selects the format and sends to predetermined addresses automatically?

I am an Access novice, so any help would be greatly appreciated.
Jan 26 '11 #1
4 1631
ADezii
8,834 Recognized Expert Expert
Use the Full Syntax of SendObject(), while stating the Output Format, as in either one of the five examples below:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.SendObject acSendReport, stDocName, acFormatDAP, "<Some E-Mail Address>", , , "<Subject of E-Mail>", "<E-Mail Message>", False
  2. DoCmd.SendObject acSendReport, stDocName, acFormatHTML, "<Some E-Mail Address>", , , "<Subject of E-Mail>", "<E-Mail Message>", False
  3. DoCmd.SendObject acSendReport, stDocName, acFormatRTF, "<Some E-Mail Address>", , , "<Subject of E-Mail>", "<E-Mail Message>", False
  4. DoCmd.SendObject acSendReport, stDocName, acFormatTXT, "<Some E-Mail Address>", , , "<Subject of E-Mail>", "<E-Mail Message>", False
  5. DoCmd.SendObject acSendReport, stDocName, acFormatXLS, "<Some E-Mail Address>", , , "<Subject of E-Mail>", "<E-Mail Message>", False
Jan 26 '11 #2
yeske03
9 New Member
Thanks, that works great now. Is there a way I can add that code to the command button I have to close the application, so that it will email the file and close when finished?
Jan 26 '11 #3
yeske03
9 New Member
Nevermind on the last post. I moved my DoCmd.Quit up a few lines and works perfectly now. Thanks for the help ADezzi.
Jan 26 '11 #4
ADezii
8,834 Recognized Expert Expert
If you wish to add the Code when you Close the Application, you should probably place it in the Close() Event of your Main Form:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Close()
  2.   DoCmd.SendObject acSendReport, stDocName, "<Format>", "<Some E-Mail Address>", , , "<Subject of E-Mail>", "<E-Mail Message>", False
  3. End Sub
Jan 26 '11 #5

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

Similar topics

1
14497
by: coder_1024 | last post by:
I'm trying to send a packet of binary data to a UDP server. If I send a text string, it works fine. If I attempt to send binary data, it sends a UDP packet with 0 bytes of data (just the headers). I can see this because I'm running Ethereal and watching the packets. I'm defining the packets as shown below: $text_msg = "Hello,...
0
522
by: praba kar | last post by:
Dear All, I have doubt regarding mail sending smtplib module. The below code is I used to send a mail. ########################################## import email.Message import email.Utils import mimetypes import os,string
3
4616
by: Robert A. van Ginkel | last post by:
Hello Fellow Developer, I use the System.Net.Sockets to send/receive data (no tcpclient/tcplistener), I made a receivethread in my wrapper, the receivethread loops/sleeps while waiting for data and then fires a datareceived event. Within the waitingloop there is a timeout function, but I want the the 'last-time-socket-used' variable set...
4
8192
by: yaron | last post by:
Hi, I have a problem when sending data over TCP socket from c# client to java server. the connection established ok, but i can't send data from c# client to java server. it's work ok with TcpClient, NetworkStream and StreamWriter classes. but with low level socket it doesn't work (When using the Socket class Send method).
3
3599
by: Ant | last post by:
Hi, I'm using the MailMessage & smtpMail classes in System.Web.Mail to send mail, however it's not sending any emails. I'm using it on a Windows 2003 server. The simplest way to use this is smtpMail.Send("from@here.com", to@there.com, "Message subject", "Message Body") I'm sending it to my own email address on a different server using...
3
7705
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 value for the UserName token. Is it possilbe at all to do this from VBScript (or jscript?)? I know I will be limited with what I can do with the SOAP...
0
1851
by: remya1000 | last post by:
by using FTP i can send files to server using vb.net. if the file is big, then it will take some time to complete the sending process to server.or if we were sending 3-4 files to the server one by one,then whethere we can show the progress of each file sending to server in progress bar. so that the FTP clients can see the progress of file...
9
3440
by: JoeP | last post by:
Hi All, How can I find the reason for such an error: Failure sending mail. Some Code... oMailMessage.IsBodyHtml = False oMailMessage.Body = cEmailBody Dim oSMTP As New SmtpClient oSMTP.Send(oMailMessage) (in this line I am getting the above err)
4
2383
by: =?Utf-8?B?R3V5IENvaGVu?= | last post by:
Hi all I use: Dim message As New MailMessage(txtTo.Text, txtFrom.Text, txtSubject.Text, txtBody.Text) Dim emailClient As New SmtpClient(txtSMTPServer.Text) emailClient.Send(message) And its working fine. However I was wondering if there is a way to confirm that the email was sent. The send method does not return anything....
6
9194
by: Chocolade | last post by:
Hi, Im using System.Net.Mail to send email in my application it was working great without any problems untill this morning after like 20-30 tries it was sending the email ok then suddenly this morning i got an exception and i cant figure out what/where the problem is and how to fix it. The problem say i have some invalid char: invalid...
0
7475
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7409
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7664
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7437
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7771
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5982
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5343
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4958
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
720
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.