Send mail using SQL Server - email

I am trying to send an email from a Trigger, on SQL Server 2008 . The data of the email will be, just a plain hardcoded text.
When user clicks on a trigger button from application my sp needs to send mail to specified users.
(Do i need to specify the users somewhere?)
Can someone provide some sample code on how to do this, please?
I've not set up any SQL mail and stuff, so I'm guessing it's built in.

like you set first you need to configure you SQL instance
Permissions
You must be a member of the sysadmin fixed server role to
use the Send Test E-Mail dialog box. Users who are not members of the
sysadmin fixed server role can test Database Mail using the
sp_send_dbmail procedure.
Procedure Using Object Explorer in SQL Server Management Studio,
connect to an instance of SQL Server Database Engine where Database
Mail is configured, expand Management, right-click Database Mail, and
then select Send Test E-Mail. If no Database Mail profiles exist, a
dialog prompts the user to create a profile and opens the Database
Mail Configuration Wizard.
In the Send Test E-Mail from dialog box, in the Database Mail Profile
box select the profile you want to test.
In the To box, type the e-mail name of the recipient of the test
e-mail.
In the Subject box, type the subject line for the test e-mail. Change
the default subject to better identify your e-mail for
troubleshooting.
In the Body box, type to body of the test e-mail. Change the default
subject to better identify your e-mail for troubleshooting.
Select Send Test E-Mail to send the test e-mail to the Database Mail
queue.
Sending the test e-mail opens the Database Mail Test E-Mail dialog
box. Make a note of the number displayed in the Sent e-mail box. This
is the mailitem_id of the test message. Select OK.
On the Toolbar select New Query to open a Query Editor window. Run the
following T-SQL statement to determine the status of the test e-mail
message:
SQL
Copy SELECT * FROM msdb.dbo.sysmail_allitems WHERE mailitem_id = ;
click here to see the documentation
here is the sintaxis to use it.
Syntax
Copy
sp_send_dbmail [ [ #profile_name = ] 'profile_name' ]
[ , [ #recipients = ] 'recipients [ ; ...n ]' ]
[ , [ #copy_recipients = ] 'copy_recipient [ ; ...n ]' ]
[ , [ #blind_copy_recipients = ] 'blind_copy_recipient [ ; ...n ]' ]
[ , [ #from_address = ] 'from_address' ]
[ , [ #reply_to = ] 'reply_to' ]
[ , [ #subject = ] 'subject' ]
[ , [ #body = ] 'body' ]
[ , [ #body_format = ] 'body_format' ]
[ , [ #importance = ] 'importance' ]
[ , [ #sensitivity = ] 'sensitivity' ]
[ , [ #file_attachments = ] 'attachment [ ; ...n ]' ]
[ , [ #query = ] 'query' ]
[ , [ #execute_query_database = ] 'execute_query_database' ]
[ , [ #attach_query_result_as_file = ] attach_query_result_as_file ]
[ , [ #query_attachment_filename = ] query_attachment_filename ]
[ , [ #query_result_header = ] query_result_header ]
[ , [ #query_result_width = ] query_result_width ]
[ , [ #query_result_separator = ] 'query_result_separator' ]
[ , [ #exclude_query_output = ] exclude_query_output ]
[ , [ #append_query_error = ] append_query_error ]
[ , [ #query_no_truncate = ] query_no_truncate ]
[ , [ #query_result_no_padding = ] #query_result_no_padding ]
[ , [ #mailitem_id = ] mailitem_id ] [ OUTPUT ]
click here to se the documetnation how to use.

Related

add another turtle's id to another turtle's attribute

In the model below, a bank can only fund customers with a credit score that matches the scores in their acceptable_scores attribute. and if it doesn't match any of the banks acceptable_scores it is rejected.
globals [
scores
]
breed [ customers customer ]
breed [ banks bank ]
customers-own [
loan_amount
credit_score
status
]
banks-own [
acceptable_scores
list_of_customers
]
to setup
clear-all
ask patches [ set pcolor 8 ]
set scores n-values 10 [random 900 + 10]
create-customers 100 [
set loan_amount random-exponential 20000
set credit_score one-of scores
set status "applied"
]
create-banks 10 [
set acceptable_scores n-of (random 3 + 1) scores
set list_of_customers []
]
reset-ticks
end
to go
ask one-of banks [
fund-loan
reject-loan
]
tick
end
to fund-loan
let person one-of customers-here with [
(member? credit_score [acceptable_scores] of myself)
]
if person != nobody [
ask person [
set status "funded"
]
set list_of_customers lput person list_of_customers
]
end
to reject-loan
let person one-of customers-here with [
(not member? credit_score [acceptable_scores] of myself)
]
if person != nobody [
ask person [
set status "funded"
]
set list_of_customers lput person list_of_customers
output-print list_of_customers
]
end
I want to add each funded customer to the list_of_customers after funding here:
set list_of_customers lput person list_of_customers
but the list is always empty when printed out. What is the right way to add another turtle's id to another turtle's attribute? In general, is this the best way to handle the funding and rejection procedures? Can it be done in one function?
Here is a pared-down version of your model using agentsets. The bank behavior may not be just what you want, but it should get you started.
globals [
scores
]
breed [ customers customer ]
breed [ banks bank ]
customers-own [
loan_amount
credit_score
status
]
banks-own [
acceptable_scores
my_customers
]
to setup
clear-all
ask patches [ set pcolor 8 ]
set scores n-values 10 [random 900 + 10]
create-customers 100 [
set loan_amount random-exponential 20000
set credit_score one-of scores
set status "applied"
]
create-banks 10 [
set acceptable_scores n-of (random 3 + 1) scores
set my_customers no-turtles
]
reset-ticks
end
to go
ask banks [
fund-loan
]
ask banks [ show my_customers ]
tick
end
to fund-loan
let person one-of customers-here
ifelse (member? [credit_score] of person acceptable_scores) and ([status] of person != "funded") [
ask person [
set status "funded"
]
set my_customers (turtle-set person my_customers)
]
[
ask person [
set status "rejected"
]
]
end

going to target and home within one tick

I want my turtles to go to a target and go home again (using fd) within the time period of one tick. The model works fine when I execute the go procedure one by one ("go once"). Execution as a loop (without altering the code), however, doesn't work: The turtles don't move; the tick counter is updated though. It seems that the functions are executed correctly but the movement is not visualized. Thanks for your help!
to go
if ticks >= 365 [ stop ]
move
if not any? turtles with [ shape = "person" and movement-done? = false ]
[
tick
ask turtles with [ shape = "person" ] [
set movement-done? false
set reached? false
set at-home-again? false ]
]
end
to move
ask turtles with [ shape = "person" ]
[
if movement-done? = false
[
ifelse reached? = false
[
ifelse patch-here = target [ set reached? true set at-home-again? false ]
[
face target
fd 1
]
]
[
ifelse at-home-again? = false
[
ifelse patch-here = myhome [ show "patch-here = myhome" set at-home-again? true ]
[
face myhome
fd 1
]
]
[
set movement-done? true
]
]
]
]
end

Firebase REST API GET request with params

I've uploaded a geojson file to my firebase realtime database and setup an http get request in my angular app to retrieve the data. Here's a small sample of my data. All it is is an array of objects. Each object is a zip code. Below are two zip code objects.
[
{
"type":"Feature",
"properties":{
"STATEFP10":"44",
"ZCTA5CE10":"02818",
"GEOID10":"4402818",
"CLASSFP10":"B5",
"MTFCC10":"G6350",
"FUNCSTAT10":"S",
"ALAND10":56516634,
"AWATER10":8882294,
"INTPTLAT10":"+41.6429192",
"INTPTLON10":"-071.4857186",
"PARTFLG10":"N"
},
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
-71.457848,
41.672076
],
[
-71.457848,
41.672414
],
[
-71.457848,
41.672932
],
[
-71.457916,
41.67407
]
]
]
}
},
{
"type":"Feature",
"properties":{
"STATEFP10":"44",
"ZCTA5CE10":"02878",
"GEOID10":"4402878",
"CLASSFP10":"B5",
"MTFCC10":"G6350",
"FUNCSTAT10":"S",
"ALAND10":75250623,
"AWATER10":8363563,
"INTPTLAT10":"+41.6101375",
"INTPTLON10":"-071.1804709",
"PARTFLG10":"N"
},
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
-71.210351,
41.656166
],
[
-71.209897,
41.657718
],
[
-71.208399,
41.660013
],
[
-71.20787,
41.661323
]
]
]
}
}
]
I can retrieve all of my data no problem but I can't seem to filter specific zip codes. I have read over the guides on firebase (https://firebase.google.com/docs/database/rest/retrieve-data) and can not get this to work with params. What I'm trying to do is filter an object based on the "ZCTA5CE10" value in "properties". I have tried many different combinations. Below is one of them:
getZipData() {
return this.http.get(this.url + '?orderBy="properties/ZCTA5CE10"&equalTo="02818"');
}
I get a 400 error when attempting to use params. What am I doing wrong?
Also, Is it possible to filter multiple zip codes E.g. &equalTo="02818"&equalTo="02878"

How to set the color of a link with another agent under condition

I would like to change the color of the links that join one agent (reader's breed) to other readers that have a flag (TM? = true). The code is something like this:
breed [ readers reader ]
undirected-link-breed [ rris rri ]
readers-own [ TM? ]
to start-TM [ ?reader ]
ask ?reader [
if any? other readers with [ TM? = true ] [
let other-TM-readers other readers with [ TM? = true ]
ask my-rris with [other-TM-readers] [ set color red ]
]
]
end
which returns me an error in the line ask my-rris with [other-TM-readers] [ set color red ] because with is expecting true or false and not an agentset.
How could I select the rri links that connects current ?reader with the readers that have TM? = true?
Regards
When you write:
let other-TM-readers other readers with [ TM? = true ]
you tell NetLogo to assign the agentset of all the readers for which TM is true to the other-TM-readers variable. So when you then write:
ask my-rris with [other-TM-readers] [ set color red ]
you are passing the other-TM-readers agentset to with, just like NetLogo is saying in its error message.
This is easy to fix, but first, a comment: writing = true is almost always superfluous. Your TM? variable is already a boolean, so you can check for it directly by writing with [ TM? ] instead of with [ TM? = true ].
Now, to fix the error, you can write:
let other-TM-readers other readers with [ TM? ]
ask other-TM-readers [
ask rri-with myself [ set color red ]
]
or just:
ask other readers with [ TM? ] [
ask rri-with myself [ set color red ]
]
You could also ask the links directly, and use the other-end primitive to check the color of the neighbors:
ask my-rris with [ [ TM? ] of other-end ] [ set color red ]
That last version is also safer than the previous versions, because it does not assume that there is a link between the caller and the other readers: it will only ask the links that are actually present. (The first two versions could check that rri-with myself != nobody, but that would be less elegant.)

What is the mean of [-] and [+] in silktest script

I got a project to convert Silk Test to some other GUI testing framework. I can't understand how the Silk Test script organized by [-] and [+] signs.
are there someone help me to understand the meaning? Here is a sample script
[+] if(AssignSymbolToCatalogNumber.Exists(4))
[ ] AssignSymbolToCatalogNumber.setActive()
[ ] Sleep(1)
[ ] AssignSymbolToCatalogNumber.notMapToCatalog.SetFocus()
[ ] AssignSymbolToCatalogNumber.notMapToCatalog.Click()
[ ] WaitForDialogExists (Keep)
[-] if !Keep1.Exists (1)
[ ] ResLog.LogFail ("The number {i} Keep dialog did not pop up!")
[ ] goto EndProgram
[-] else
[ ] Keep1.SetActive ()
[ ] Keep1.RadioList1RL.Select ("#1")
[ ] Keep1.ShowEditDialogAfterEachCK.Check ()
[ ] Keep1.OK.Click ()
[ ]
[ ] WaitForDialogExists (InsertEditChildComponent)
[-] if !InsertEditChildComponent.Exists (1)
[ ] ResLog.LogFail ("Insert/Edit child component dialog did not pop up!")
[ ] goto EndProgram
[-] else
[ ] InsertEditChildComponent.SetActive ()
[ ] InsertEditChildComponent.ParentSiblingPB.Click ()
[ ]
[ ] Sleep (1)
In Silk Test's 4Test language, blocks are indicated by an additional tab-character in the indentation, similar to Python.
The [+] and [-] tags are an indication for the code-editor that a new block begins and also encode the folding status of that block. That means that when you fold that block in the IDE, it will become [-] and if you open it up again, it will become [+].
For the purpose of running a script they make no difference, it's only relevant for displaying the code.