Results 1 to 4 of 4

Thread: HELP! on email and SQL

  1. #1

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Angry

    This is my situation:

    I have an application where users enter data (duh!lol) and save it in the SQL database I have created. What I would like to know is: is there a way where once the user has entered the data and clicked save, the data (in a report format) is emailed to the person that was specified in the data entry.

    I hope this isn't confusing. Any assistance would be appreciated.

  2. #2
    Addicted Member
    Join Date
    Jan 2000
    Location
    Fresno, California, USA
    Posts
    195
    This is how we do it. We store the stuff in our DB. We have a separate program that reads that data base and sends the e-mails. Our program also updates calendars and tasks, so it uses Outlook. There are several examples within the last couple of weeks in this forum of different ways to send e-mail. Check them out and see which is the best for your application. Hope this helps.

  3. #3
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    Yes...

    There is a way... (There could a better one) but Ok...
    I am not giving u a true report format but mail the
    results of a SQL

    Once u click SAVE and the data is actually saved
    then select from the table where the data is saved

    say:
    "Select * from table where whatever"
    into a recordset

    then loop throught the recordset to populate
    the body of the e-mail

    Now, if u can get there

    in your VB, Project, Add a reference to OUTLOOK Object module.

    Write a function Email similar to the one below

    Public Sub EmailUs()
    Dim objOutlook As New outlook.Application
    Dim objOutlookMsg As New outlook.MailItem
    Dim rs_MyRS As New ADODB.Recordset

    Dim ls_SqlString As String

    ls_SqlString = "select * from tblName where Yourcriteria"

    Set rs_MyRS = Execute your sql the way u know how here

    If rs_MyRS Is Nothing Then
    '
    else
    Do Until rs_MyRS.EOF
    ' Create new message
    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

    With objOutlookMsg
    .To = Youremail
    .Subject = "This is the data just saved!"

    'There u can format it any way you want....
    .body = .body & rs_MyRS.fields(0) & vbnewLine
    .body = .body & " Good Luck!"

    .Importance = olImportanceHigh

    .Send

    End With

    rs_MyRS.MoveNext
    Loop

    set objOutlookMsg = nothing

    let me know how it works out

  4. #4

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Thumbs up Thanks...but one more question

    Thank you very much for your help. Lafor, I am using your example as a base and working on it from there. I have not tried it yet but will let you know soon. My new question is this: Is there a way I can populate a list box with the Outlook recipients list on our exchange server? And can the list be set up in away that the box refreshes itself?(you know, just in case the admin adds a new email address to the list)

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width