Sending auto email from database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shaugat
    New Member
    • Jul 2006
    • 3

    Sending auto email from database

    I need help. I want to send auto e-mail if a value of a field is higher than a set value. For an example, if someone's systolic blood pressure is more than 140, this value will be automatically be e-mail along with the patients id number. And I like the database to do the same whenever a value is higher than the set value to be e-mail. I will be very grateful if anyone can tell me how to do that. Thanks.
  • comteck
    New Member
    • Jun 2006
    • 179

    #2
    Try "SendObject " under macros.

    comteck

    Comment

    • comteck
      New Member
      • Jun 2006
      • 179

      #3
      Sorry about that response. You did say you wanted to do it automatically. Ok, forget the macro. Do it using code instead. The format is as follows:

      expression.Send Object(ObjectTy pe, ObjectName, OutputFormat, To, Cc, Bcc, Subject, MessageText, EditMessage, TemplateFile)

      Most of these fields are optional, but you must use separators for them.

      Assume the field on your form with the e-mail address is called txtEmailAddr, and the report you want to send is called "Report1". Add the following code to the OnClick Event of a command button:

      Private Sub Command6_Click( )
      Dim emailaddr As String
      emailaddr = Me.txtEmailAddr

      DoCmd.SendObjec t acSendReport, _
      "Report1", , emailaddr, , , "Report One", , False

      End Sub

      Hope this helps.
      comteck

      Comment

      • shaugat
        New Member
        • Jul 2006
        • 3

        #4
        Thank you. But I want to send if any person's Blood pressure value is more than 140 or lets say if anyone has Hypertension, nto all the records. Beside I want to it send this info if a new patient who has hypertension is entered.
        Can I do that? Thanks.

        Comment

        • comteck
          New Member
          • Jun 2006
          • 179

          #5
          Ok, you should be able to modify this code to make it fit your application. For example, for the hypertension, you can use the "LostFocus" for a textbox with a name of, say, "txtConditi on". The code would be as follows:

          Private Sub txtCondition_Lo stFocus()
          Dim emailaddr As String
          emailaddr = Me.txtEmailAddr

          If Me.txtCondition = "hypertensi on" Then
          DoCmd.SendObjec t acSendReport, _
          "Report1", , emailaddr, , , "Report One", , False
          End If

          End Sub

          You can then do the same for the blood pressure textbox.

          If you wanted to check either one or the other on the same form, then you can use the OnClose event procedure for the form:

          Private Sub Form_Close()
          Dim emailaddr As String
          emailaddr = Me.txtEmailAddr

          If Me.txtCondition = "hypertensi on" Or Me.txtBloodPres sure > 140 Then
          DoCmd.SendObjec t acSendReport, _
          "Returns Report", , emailaddr, , , "Report One", , False
          End If

          End Sub

          I assume it's a different report for each condition, so I would recommend to keep it separate.

          Not sure if this is what you are looking for, but, either way, the "SendObject " command is what you would use to send files via e-mail.

          comteck

          Comment

          • shaugat
            New Member
            • Jul 2006
            • 3

            #6
            Thank you so much. I have not tried it yet. I will be doing that on monday and I will let you know. I have one more question, my database will be used daily. Is there anyway, sending hypertension status of all the patient on the day they were entered not all of the previously entered patient's status?

            Comment

            • jaytrader
              New Member
              • Aug 2006
              • 2

              #7
              I am needing to do something very similar. However,...When a particular Cells data is = -1 then I need to send that contacts data as an E-mail TEXT with the labels such as....

              First_Name: John
              Last_Name: Smith
              Address: 12345 TBD

              and so forth
              NOT as a TEXT FILE attatchment but as TEXT in the email body...

              BTW the table needs to be auto updated about every 5-10 minutes....

              then when that particular cell is = -1 then that triggers the email event...

              ThX

              Comment

              • India62
                New Member
                • Apr 2008
                • 1

                #8
                Hi I need help in similar way
                I need daily auto e mail of some report (except Sunday)
                How can I write this code
                Thanks in advance


                Originally posted by comteck
                Ok, you should be able to modify this code to make it fit your application. For example, for the hypertension, you can use the "LostFocus" for a textbox with a name of, say, "txtConditi on". The code would be as follows:

                Private Sub txtCondition_Lo stFocus()
                Dim emailaddr As String
                emailaddr = Me.txtEmailAddr

                If Me.txtCondition = "hypertensi on" Then
                DoCmd.SendObjec t acSendReport, _
                "Report1", , emailaddr, , , "Report One", , False
                End If

                End Sub

                You can then do the same for the blood pressure textbox.

                If you wanted to check either one or the other on the same form, then you can use the OnClose event procedure for the form:

                Private Sub Form_Close()
                Dim emailaddr As String
                emailaddr = Me.txtEmailAddr

                If Me.txtCondition = "hypertensi on" Or Me.txtBloodPres sure > 140 Then
                DoCmd.SendObjec t acSendReport, _
                "Returns Report", , emailaddr, , , "Report One", , False
                End If

                End Sub

                I assume it's a different report for each condition, so I would recommend to keep it separate.

                Not sure if this is what you are looking for, but, either way, the "SendObject " command is what you would use to send files via e-mail.

                comteck

                Comment

                Working...