473,326 Members | 2,438 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 email from Access

I would like to send an email from Access. I copied the code from another
free website, but it does not do everything I need it to do. I have a series
of checkboxes:

checkbox1 - when checked, I want to display orange
checkbox2 - when checked, I want to display apples
checkbox3 - when checked, I want to display grapes
If all three checked, I want to display in one column:
orange
apples
grapes

So what I want to do is in the body of the email, have "Thank you for
ordering our fruit. We show you ordered the below fruits:

orange
apples
grapes
(depending on what checkboxes were checked, put in the fruits ordered.)

Then I want a closing paragraph,i.e.
We look forward to your business in the future.

Sincerely,

Here's my code so far. Thanks in advance.

How do I incorporate the option to put in my checkboxes on the form:

Private Sub Command29_Click()
On Error GoTo Err_Command0_Click

Dim stext As String
Dim sAddedtext As String

If Len(txtMainAddresses) Then
stext = txtMainAddresses
End If
If Len(txtCC) Then
sAddedtext = sAddedtext & "&CC=" & txtCC
End If
If Len(txtBCC) Then
sAddedtext = sAddedtext & "&BCC=" & txtBCC
End If
If Len(txtSubject) Then
sAddedtext = sAddedtext & "&Subject=" & txtSubject
End If
If Len(txtBody) Then
sAddedtext = sAddedtext & "&Body=" & txtBody
End If
If Len(txtAttachment) Then
sAddedtext = sAddedtext & "Attach=" & Chr$(34) & txtAttachment & Chr$
(34)
End If

stext = "mailto:" & stext

If Len(sAddedtext) <> 0 Then
Mid$(sAddedtext, 1, 1) = "?"
End If

stext = stext & sAddedtext & myString

' launch default e-mail program
If Len(stext) Then
Call ShellExecute(hwnd, "open", stext, vbNullString, vbNullString,
SW_SHOWNORMAL)
End If
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
'End If
End Sub
Nov 13 '05 #1
3 2075
icsupt via AccessMonster.com wrote:
I would like to send an email from Access. I copied the code from another
free website, but it does not do everything I need it to do. I have a series
of checkboxes:

checkbox1 - when checked, I want to display orange
checkbox2 - when checked, I want to display apples
checkbox3 - when checked, I want to display grapes
I suggest you name your checkboxes, something like
chkOrange
chkApple

etc. :-)
So what I want to do is in the body of the email, have "Thank you for
ordering our fruit. We show you ordered the below fruits:

orange
apples
grapes
(depending on what checkboxes were checked, put in the fruits ordered.)

Then I want a closing paragraph,i.e.
We look forward to your business in the future.

Sincerely, Private Sub Command29_Click()
On Error GoTo Err_Command0_Click

Dim stext As String
Dim sAddedtext As String [snip] If Len(txtBody) Then
sAddedtext = sAddedtext & "&Body=" & txtBody
End If


It appears to me the whole email message is taken from the control
txtBody. It is probably not this routine that should insert the fruits,
but some other event on the form.

Or, you'd have to split up the text, according to some parameter
indicator (Mac uses ^1, ^2 ... for variable texts in its code, I like
that) and insert values. Just before this if...end if is the place to do
this.

Have a look at docmd.sendobject acsendnoobject as well. You can send a
message with 'native' code, if you have a registered email client on the
machine running Access.
--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html

Nov 13 '05 #2
icsupt via AccessMonster.com wrote:
I would like to send an email from Access. I copied the code from another
free website, but it does not do everything I need it to do.

<snip>

What you really might want to try is using the CDONTS object. In VBA, do
Tools->References, and look for the "Microsoft CDO for NTS" library.

This will let you send to an SMTP gateway, for example, and probably the
most important for you, lets you define the From and Reply-To values
(even for Exchange...). Most of the other methods depend on you having
Outlook active and hooked up to Exchange, and will refer the e-mail sent
back to your e-mail account, and won't let you set the From or Reply-To
values to a different mail box.

when installing Outlook 2003, I think if you do a Custom installation,
it's an X'd-out option, but if you check it, it'll be included.

It's old-school, but it's really the most flexible method, especially if
you are not using Exchange & Outlook.

There is some trickery involved if you are indeed using Exchange but
don't have Outlook open, because you need it to login to Exchange as you.
Nov 13 '05 #3
corey lawson wrote:
icsupt via AccessMonster.com wrote:
I would like to send an email from Access. I copied the code from another
free website, but it does not do everything I need it to do.

<snip>

What you really might want to try is using the CDONTS object. In VBA, do
Tools->References, and look for the "Microsoft CDO for NTS" library.

This will let you send to an SMTP gateway, for example, and probably the
most important for you, lets you define the From and Reply-To values
(even for Exchange...). Most of the other methods depend on you having
Outlook active and hooked up to Exchange, and will refer the e-mail sent
back to your e-mail account, and won't let you set the From or Reply-To
values to a different mail box.

when installing Outlook 2003, I think if you do a Custom installation,
it's an X'd-out option, but if you check it, it'll be included.

It's old-school, but it's really the most flexible method, especially if
you are not using Exchange & Outlook.

There is some trickery involved if you are indeed using Exchange but
don't have Outlook open, because you need it to login to Exchange as you.


There is also the pure SMTP method that Tony has documented on his
site, which doesn't require CDO at all.

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Google Mike | last post by:
I've got RH9 Linux with default PHP. Is there a way to send email on Linux to an Exchange Server from PHP and/or other tools when there is *NOT* SMTP access? Has anyone figured out a way to...
4
by: jas | last post by:
I have a basic client/server socket situation setup....where the server accepts a connection and then waits for commands. On the client side, I create a socket, connect to the server...then I...
1
by: Jay McGrath | last post by:
Help - trying to send a simple text email with with as little user intervention. I am trying to create a button in my Access application that will automatically send a simple text email. It...
11
by: Tim Smallwood | last post by:
Hi, I have an Access project that I use to allow a client to hit an SQL server at my host. This project has several forms that are used to udpate tables, etc, but I'd also like to be able to...
4
by: Colin Kingston | last post by:
Hi For a college project I intend to produce a web based access database which will allow a group leader to send the same email to group members registered for that group. I want the group...
4
by: Ranganath Udupa | last post by:
I need to include a mail to a concerned person whenever a button is clicked in an Access form. So I used the DoCmd.SendObject command. However, it seems like I cannot send a long message text. Is...
3
by: Gerard | last post by:
Hello I have created a windows service to monitor a database, it starts some checks when a timer elapses. The checks send emails depending on their findings. My issue is that when I created a...
17
by: DP | last post by:
hi, is there a way to send an e-mail to a customer, using ms access?? or some kind of automated mail merge, so the user only has to review the body, and click send? ive got a customer table,...
14
by: supz | last post by:
Hi, I use the standard code given below to send an email from an ASP.NET web form. The code executes fine but no Email is sent. All emails get queued in the Inetpub mail queue. I'm using my...
10
by: Mike Charney | last post by:
Is there a simple way to send SMTP email from Access VBA? Mike m charney at dunlap hospital dot org
0
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.