There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Business Applications
Tag Cloud
audio blue blue screen boot bsod compaq computer cpu crash dell drivers dvd error excel firefox format freeze freezing hard drive hardware install internet internet explorer kb951748 lan laptop loss of internet malware memory motherboard network networking outlook outlook 2007 problem restart screen security slow sound trojan update virus vista windows windows xp winxp wireless zonealarm zone alarm
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Business Applications >
Solved: Microsoft Access again


Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members. Enjoy!

 
Thread Tools
redhotsonic's Avatar
Junior Member with 28 posts.
 
Join Date: Oct 2008
Experience: Intermediate
13-Oct-2008, 06:53 PM #1
Solved: Microsoft Access again
Hello, I have another problem that I just can't figure out.

I have a query table that I would liek to be able to send as an e-mail. But here is the thing. I have a button on a form that just opens up the query table, but what I would like the button to do, is to make the e-mail pop-up (Outlook2007 at home, GroupWise at work) and put the query data in the message. Basically, when you click the button, I want this:

To:
CC:
BC:
Subject: "Good morning"
Message: "(My query table here)"

I found a code elsewhere on the internet but I got code errors. I then fixed the errors but then the button simply did nothing.

If anyone can help, I'd really appreciate it.

Many Thanks in advance
redhotsonic
slurpee55's Avatar
Computer Specs
Distinguished Member with 4,517 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
14-Oct-2008, 07:14 AM #2
The quickest way to figure it out without reinventing the wheel is for you to post the code you have and someone can diagnose it.
redhotsonic's Avatar
Junior Member with 28 posts.
 
Join Date: Oct 2008
Experience: Intermediate
14-Oct-2008, 08:48 AM #3
This is the code I got from the net:

Code:
Private Sub CmdEmail_Click()
Dim rsEmail As DAO.Recordset
Dim strEmail As String
Dim strBody As String
Dim strSubject As String
Dim strContactName As String
Set rsEmail = CurrentDb.OpenRecordset("YourQuery")
 
Do While Not rsEmail.EOF
strEmail = rsEmail.Fields("Email").Value
strBody = rsEmail.Fields("Body").Value
strContactName = rsEmail.Fields("ContactName").Value
strSubject = "blah blah blah"
 
DoCmd.SendObject , , , strEmail, , , _strSubject, _"Yourtexthere " & strContactName & vbCrLf & vbCrLf & strBody, True
 
rsEmail.MoveNext
 
Loop
Set rsEmail = Nothing
End Sub
This was found here.

Many Thanks

Last edited by redhotsonic : 14-Oct-2008 08:49 AM. Reason: Tags were wrong.
slurpee55's Avatar
Computer Specs
Distinguished Member with 4,517 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
14-Oct-2008, 10:16 AM #4
And from your link, "Just make sure that the fields : Email, Body and Contactname are in YourQuery."
Did you?
redhotsonic's Avatar
Junior Member with 28 posts.
 
Join Date: Oct 2008
Experience: Intermediate
14-Oct-2008, 11:40 AM #5
I didn't have them fields in my query so I delted them three lines, but I got lots of errors. So I added them to the form and query but still got errors.

This line is always a problem:

Code:
DoCmd.SendObject , , , strEmail, , , _strSubject, _"Yourtexthere " & strContactName & vbCrLf & vbCrLf & strBody, True
Always one of these:
Invalid
Expected =
Expected expression
slurpee55's Avatar
Computer Specs
Distinguished Member with 4,517 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
14-Oct-2008, 01:16 PM #6
Quote:
Originally Posted by redhotsonic View Post
I didn't have them fields in my query so I delted them three lines, but I got lots of errors. So I added them to the form and query but still got errors.

This line is always a problem:

Code:
DoCmd.SendObject , , , strEmail, , , _strSubject, _"Yourtexthere " & strContactName & vbCrLf & vbCrLf & strBody, True
Always one of these:
Invalid
Expected =
Expected expression
Well, I am not sure, but I think that at least "strContactName" is the recipient's name. And I am pretty sure that this
strEmail = rsEmail.Fields("Email").Value
tells it to look in a field called Email for the value - that is, the email to send to.
__________________
Iowa? I could have sworn this was heaven.
Well, I think I can answer this question most successfully in mime.

My theme song...
OBP's Avatar
OBP OBP is offline
Computer Specs
Distinguished Member with 6,863 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
14-Oct-2008, 01:29 PM #7
Let me know if this simple emailing database works for you.
We can take it from there.
Attached Files
File Type: zip email v1.zip (12.7 KB, 7 views)
slurpee55's Avatar
Computer Specs
Distinguished Member with 4,517 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
14-Oct-2008, 01:32 PM #8
Thanks, my friend, for coming.
slurpee55's Avatar
Computer Specs
Distinguished Member with 4,517 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
14-Oct-2008, 01:39 PM #9
Here's another one I found here:
http://www.jephens.com/2007/05/13/ho...-using-outlook
Attached Files
File Type: zip email02.zip (24.0 KB, 2 views)
MRdNk's Avatar
Computer Specs
Senior Member with 284 posts.
 
Join Date: Apr 2007
Experience: Pretty Darn Good at Excel
14-Oct-2008, 02:38 PM #10
Is it not working because Outlook isn't being called?
OBP's Avatar
OBP OBP is offline
Computer Specs
Distinguished Member with 6,863 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
14-Oct-2008, 02:47 PM #11
The Docmd.SendObject Statement normally opens Outlook without the need to call it.
redhotsonic's Avatar
Junior Member with 28 posts.
 
Join Date: Oct 2008
Experience: Intermediate
15-Oct-2008, 10:11 AM #12
email1.zip worked but email2.zip didn't. Possibly because I'm at work at the moment and it uses GroupWise? I'll see if email2.zip works when at home later because I have outlook then.

Anyway, email1 is simaler to what I want. Just the query data is what I want in the message (body1, body2, etc) and maybe thethat's it. I would like to put the email address in myself when the e-mail comes up.
OBP's Avatar
OBP OBP is offline
Computer Specs
Distinguished Member with 6,863 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
15-Oct-2008, 10:21 AM #13
Can you supply an example of what your Query data looks like, i.e. how many records, how many fields and what type of fields?
redhotsonic's Avatar
Junior Member with 28 posts.
 
Join Date: Oct 2008
Experience: Intermediate
15-Oct-2008, 03:00 PM #14
Quote:
Originally Posted by OBP View Post
Can you supply an example of what your Query data looks like, i.e. how many records, how many fields and what type of fields?
Sure.



This is the form I have. I've made a "E-mail?" button that when you click on it, the record automatically saves and will be included in the query. Then, when you click the "Set-Up E-mail" button, it brings up this:



But, what I actually want it to do is do this (from the query above without loading it):



The text in this e-mail that are red and bold is text I added in. Is it possible to actually put that within the message? I just can't make this happen.

Many Thanks in advance
redhotsonic

P.S. None of this data contains confidential information; I got rid of that =P
OBP's Avatar
OBP OBP is offline
Computer Specs
Distinguished Member with 6,863 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
15-Oct-2008, 03:19 PM #15
Of course it is possible, so you want as many rows in the Body of the email as there are rows in the Query?
You also want some text that you input, like in my email either side of the Query rows?
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 03:23 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.