1. 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.

Solved: Microsoft Access again

Discussion in 'Business Applications' started by redhotsonic, Oct 13, 2008.

Thread Status:
Not open for further replies.
Advertisement
  1. redhotsonic

    redhotsonic Thread Starter

    Joined:
    Oct 8, 2008
    Messages:
    28
    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
     
  2. slurpee55

    slurpee55

    Joined:
    Oct 20, 2004
    Messages:
    7,837
    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.
     
  3. redhotsonic

    redhotsonic Thread Starter

    Joined:
    Oct 8, 2008
    Messages:
    28
    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
     
  4. slurpee55

    slurpee55

    Joined:
    Oct 20, 2004
    Messages:
    7,837
    And from your link, "Just make sure that the fields : Email, Body and Contactname are in YourQuery."
    Did you?
     
  5. redhotsonic

    redhotsonic Thread Starter

    Joined:
    Oct 8, 2008
    Messages:
    28
    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
     
  6. slurpee55

    slurpee55

    Joined:
    Oct 20, 2004
    Messages:
    7,837
    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.
     
  7. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    Let me know if this simple emailing database works for you.
    We can take it from there.
     

    Attached Files:

  8. slurpee55

    slurpee55

    Joined:
    Oct 20, 2004
    Messages:
    7,837
    Thanks, my friend, for coming. (y) :)
     
  9. slurpee55

    slurpee55

    Joined:
    Oct 20, 2004
    Messages:
    7,837

    Attached Files:

  10. MRdNk

    MRdNk

    Joined:
    Apr 7, 2007
    Messages:
    439
    Is it not working because Outlook isn't being called?
     
  11. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    The Docmd.SendObject Statement normally opens Outlook without the need to call it.
     
  12. redhotsonic

    redhotsonic Thread Starter

    Joined:
    Oct 8, 2008
    Messages:
    28
    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.
     
  13. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    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?
     
  14. redhotsonic

    redhotsonic Thread Starter

    Joined:
    Oct 8, 2008
    Messages:
    28
    Sure.

    [​IMG]

    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:

    [​IMG]

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

    [​IMG]

    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
     
  15. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    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?
     
  16. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/758865

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice