By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,647 Members | 1,444 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,647 IT Pros & Developers. It's quick & easy.

Sending auto email from database

P: 3
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.
Jul 28 '06 #1
Share this Question
Share on Google+
7 Replies


100+
P: 179
Try "SendObject" under macros.

comteck
Jul 28 '06 #2

100+
P: 179
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.SendObject(ObjectType, 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.SendObject acSendReport, _
"Report1", , emailaddr, , , "Report One", , False

End Sub

Hope this helps.
comteck
Jul 28 '06 #3

P: 3
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.
Jul 28 '06 #4

100+
P: 179
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, "txtCondition". The code would be as follows:

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

If Me.txtCondition = "hypertension" Then
DoCmd.SendObject 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 = "hypertension" Or Me.txtBloodPressure > 140 Then
DoCmd.SendObject 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
Jul 29 '06 #5

P: 3
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?
Jul 30 '06 #6

P: 2
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
Aug 1 '06 #7

P: 1
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


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, "txtCondition". The code would be as follows:

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

If Me.txtCondition = "hypertension" Then
DoCmd.SendObject 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 = "hypertension" Or Me.txtBloodPressure > 140 Then
DoCmd.SendObject 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
Apr 17 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.