kasni84
Posts: 16
|
Posted: 10/09/2011, 3:04 AM |
|
How to send email in this situation:
1. Get email address from current UserLogin and sent tosomeone@some.com
(UserLogin = 'username' field from table user) Select email FROM user WHERE username == (CCGetUserLogin())
2. Get email address from current UserLogin and sent to current logged user.
i read the exmaple but dont understand
global $DBIntranetDB; //what is my database name? is it the ODBC name?
global $tasks; // what is this variable?
$from_name = CCDLookUp("emp_name", "employees", "emp_id=".
$DBIntranetDB->ToSQL(CCGetUserID(), ccsInteger), $DBIntranetDB);// get username?
$from_email = CCDLookUp("email", "employees", "emp_id=".
$DBIntranetDB->ToSQL(CCGetUserID(), ccsInteger), $DBIntranetDB);//get email? cant see email field call etc
$to_email = CCDLookUp("email", "employees", "emp_id=".//to email? where's the email?
$DBIntranetDB->ToSQL($tasks->user_id_assign_to->GetValue(), ccsInteger), $DBIntranetDB);
$headers = "From: ".$from_name."<".$from_email.">;\r\n";
$headers .= "Content-Type: text/html";
$subject = "New task for you";
$message = "The following task was submitted:<br><br>".
"Task ID: ".CCDLookUp("max(task_id)", "tasks", "user_id_assign_by=".
$DBIntranetDB->ToSQL(CCGetUserID(), ccsInteger), $DBIntranetDB)."<br><br>".
$tasks->task_desc->GetText();
mail ($to_email,$subject,$message,$headers);
|
|
|
mamboBROWN
Posts: 1713
|
Posted: 10/09/2011, 3:23 PM |
|
kasni84,
What is it that you don't understand? How the code is getting the information or where to put the code?
|
|
|
kasni84
Posts: 16
|
Posted: 10/12/2011, 5:58 AM |
|
i dont understand how to get email value from table user where Userlogin=username (How the code is getting the information) i know where to put the code :)
database name = conmas
table name 1 = user (field = username, email)PKEY username
table name 2 = abstract (field = abs_id, username) PKEY abs_id *one user can send many abs_id
i want to send notification via email which abs_id are accepted. so basically get email address which username's abs_id are accepted.
SELECT email FROM user WHERE username = SELECT username FROM abstract WHERE abs_id = abs21. how to code this sql to the example code found on the documentation
$to_email = CCDLookUp("email", "employees", "emp_id=".
$DBIntranetDB->ToSQL($tasks->user_id_assign_to->GetValue(), ccsInteger), $DBIntranetDB);
so from the example above,
$to_email = CCDLookUp("email", "user", "username=". $conmas->ToSQL($username->email->GetValue()), $conmas);
question;
1. what does the arrow mean ->
2. what is ToSQL ?
3. is my code right? i tried but no email send. confuse with the syntax. can you show me the full right code? Please help....
4. should i declare $DBIntranetDB as global $DBIntranetDB? in my case global $conmas? my odbc name is conmas_odbc, the real database name on the server is commas.
|
|
|
datadoit
|
Posted: 10/12/2011, 6:17 AM |
|
There's an Action Event that will do what you want: http://docs.codecharge.com/studio40/html/QuickStart/Cre...gEventsPHP.html
No programming required.
|
|
|
benjohn
Posts: 30
|
Posted: 10/12/2011, 3:25 PM |
|
yep CCS has a built-in action that you could use to send email. say after update event right-click choose action then choose send email. fill up the values then the rest is magic hope this helps... all the best!
pal,
Benjohn
_________________
~=~=~=~=~=~=~=~=~=~=~=
get it done. make it happen.
~=~=~=~=~=~=~=~=~=~=~= |
|
|
kasni84
Posts: 16
|
Posted: 10/13/2011, 12:47 AM |
|
After right click and choose action send email, in the drop down to email, i can only see field for current selected database.table user were not selected during record builder because i only need to update table abstract so i cant see email field when i click drop down to email.
So how to get email address from table user where username from table user equal to username on table abstract? i tried using custom insert with SQL type but got lost.
I really need help....please...
|
|
|
kasni84
Posts: 16
|
Posted: 10/13/2011, 1:09 AM |
|
i tried to get email value then show it in a label, if this code success mean i can save email value to abstract so that i can easily know email for each abs_id. i'm so confuse which way to do it.
$Container->presenter_email->CCDLookUp($email,$user, $username=CCGetUserLogin(), & $conmas)
but then get this error
Parse error: syntax error, unexpected T_RETURN
|
|
|
benjohn
Posts: 30
|
Posted: 10/13/2011, 3:00 AM |
|
hi there kasni84,
Good Day!
you're actually there already. say on the said Table, on the AfterInsert event create the Send Email Action. Double click on the Send Email Action, there you could insert some php scripts. so for example you need the email you could try to use
global $DBConnection; //replace with your connection
ini_set("SMTP", "localhost");
$to = CCDLookUp("email","user","username=".$DBConnection->ToSQL(CCGetUserLogin(),ccsText),$DBConnection);
hope this helps... all the best!
pal,
Benjohn
_________________
~=~=~=~=~=~=~=~=~=~=~=
get it done. make it happen.
~=~=~=~=~=~=~=~=~=~=~= |
|
|
kasni84
Posts: 16
|
Posted: 10/13/2011, 7:24 AM |
|
thanks benjohn for your help
this code works,
$db = new clsDBconmas_odbc();
$acik = CCDLookUp("email","user","username='user1'"), $db);
$db->close();
echo $acik;
it can also be like this
$db = new clsDBconmas_odbc();
$sql = "SELECT email FROM user WHERE username ='user1'";
$db->query($sql);
$Result = $db->next_record();
if ($Result) {
$acik = $db->f("email");
}
$db->close();
i got it working if i set the value
$acik = CCDLookUp("email","user","username='user1'";
i echo $acik and email address were showed, but when i tried to get username value form a textbox inside a record builder it return nothing.
[/IMG]
i tried username textbox which were generated by record builder but no return value, then i tried adding new textbox
which one?
1. $acik = CCDLookUp("email","user","username=".$Container->TextBox1->GetValue(), $db);
2. $acik = CCDLookUp("email","user","username={TextBox1}";
3. $acik = CCDLookUp("email","user","username=".$TextBox1;
how to do it correctly?
|
|
|
benjohn
Posts: 30
|
Posted: 10/13/2011, 7:09 PM |
|
it should be $Container->username->GetValue();
hope this helps... all the best!
pal,
Benjohn
_________________
~=~=~=~=~=~=~=~=~=~=~=
get it done. make it happen.
~=~=~=~=~=~=~=~=~=~=~= |
|
|
kasni84
Posts: 16
|
Posted: 10/13/2011, 7:35 PM |
|
GOT IT!
$db = new clsDBconmas_odbc();
$acik = CCDLookUp("email","user","username=".$db->ToSql($Container->username->GetValue(),ccsText), $db);
$db->close();
echo $acik;
i put it on Before execute update, now i'm going to try to send email to see if its working
thanks benjohn
|
|
|
benjohn
Posts: 30
|
Posted: 10/14/2011, 7:38 AM |
|
am glad you got it working... all the best!
pal,
Benjohn
_________________
~=~=~=~=~=~=~=~=~=~=~=
get it done. make it happen.
~=~=~=~=~=~=~=~=~=~=~= |
|
|
kasni84
Posts: 16
|
Posted: 10/18/2011, 2:41 AM |
|
Successfully sending email using phpmailer. A big thanks to benjohn for helping me!
|
|
|
Waspman
Posts: 948
|
Posted: 10/18/2011, 7:01 AM |
|
Anyone had a problem with inbuilt action causing Malformed Mime emails?
_________________
http://www.waspmedia.co.uk |
|
|
kasni84
Posts: 16
|
Posted: 10/18/2011, 5:23 PM |
|
I can't send email via mail function or the built-in send email action so don't know if it will cause malformed mime email(using the same setting as in phpmailer, got error about IsSMTP() in the server log, i guess its my server settings etc). using mail function can only send email in internal network. sending using phpmailer to yahoo,gmail and hotmail get straight to the inbox.
|
|
|
|