473,473 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Create 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 1618
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
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...
0
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...
3
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...
4
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...
3
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...
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...
0
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...
9
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...
4
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...
6
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...
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
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...
1
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...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
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...

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.