Welcome Guest, Not a member yet? Register   Sign In
Sending multiple email which is related to the other field in database
#1

[eluser]FreshProgrammer[/eluser]
Below is my table;

Table_name=empdetail
-id
-name
-department
-email

The department consist of various type of department,and for example i just wanna send email form finance department.But the problem,all emails in database were sent.Thus, how i can sent multiple email which from finance department only.


Following shows the code for send multiple email from database.It was success
In Controller

Code:
function send_email()
{
        
    $this->load->library('email');    
    foreach ($query->result() as $row)
        {
            $this->email->set_newline("\r\n");
            $this->email->from('[email protected]', 'hensem');
            $this->email->to($row->email);
            $this->email->subject('when');
            $this->email->message('ohaiyokkkk');
            $this->email->send();
             sleep(1);
         }  
}

Then,i add some code to send multiple email which is from selected department
In controller


Code:
function send_email()
    {
        
        $this->load->library('email');
        
        $this->input->post('dept');
        $query=$this->db->get_where('empdetail', array('dept' => $dept));
        
        
        foreach ($query->result() as $row)
        {
            $this->email->set_newline("\r\n");
            $this->email->from('[email protected]', 'hensem');
            $this->email->to($row->email);
            $this->email->subject('when');
            $this->email->message('ohaiyokkkk');
            $this->email->send();
            sleep(1);
            
        }  

          }


Anyone can help me? Thank You
#2

[eluser]web-johnny[/eluser]
[quote author="FreshProgrammer" date="1307520173"]Below is my table;

Table_name=empdetail
-id
-name
-department
-email

The department consist of various type of department,and for example i just wanna send email form finance department.But the problem,all emails in database were sent.Thus, how i can sent multiple email which from finance department only.


Following shows the code for send multiple email from database.It was success
In Controller

Code:
function send_email()
{
        
    $this->load->library('email');    
    foreach ($query->result() as $row)
        {
            $this->email->set_newline("\r\n");
            $this->email->from('[email protected]', 'hensem');
            $this->email->to($row->email);
            $this->email->subject('when');
            $this->email->message('ohaiyokkkk');
            $this->email->send();
             sleep(1);
         }  
}

Then,i add some code to send multiple email which is from selected department
In controller


Code:
function send_email()
    {
        
        $this->load->library('email');
        
        $this->input->post('dept');
        $query=$this->db->get_where('empdetail', array('dept' => $dept));
        
        
        foreach ($query->result() as $row)
        {
            $this->email->set_newline("\r\n");
            $this->email->from('[email protected]', 'hensem');
            $this->email->to($row->email);
            $this->email->subject('when');
            $this->email->message('ohaiyokkkk');
            $this->email->send();
            sleep(1);
            
        }  

          }


Anyone can help me? Thank You[/quote]

You forgot the
Code:
$this->email->clear();
So your code will be :
Code:
function send_email()
    {
        
        $this->load->library('email');
        
        $this->input->post('dept');
        $query=$this->db->get_where('empdetail', array('dept' => $dept));
        
        
        foreach ($query->result() as $row)
        {
            $this->email->set_newline("\r\n");
            $this->email->from('[email protected]', 'hensem');
            $this->email->to($row->email);
            $this->email->subject('when');
            $this->email->message('ohaiyokkkk');
            $this->email->send();
            sleep(1);
            
        }  

          }
#3

[eluser]FreshProgrammer[/eluser]
Thanks for your respond.

Is it this code $this->email->clear(); also important?

Because,even i didnt put it,email still can be sent.

The problem is as i just mentioned above,how just i can select email from finance department only for example?

Maybe you have any idea for my problem encountered..
#4

[eluser]web-johnny[/eluser]
[quote author="FreshProgrammer" date="1307521148"]Thanks for your respond.

Is it this code $this->email->clear(); also important?

Because,even i didnt put it,email still can be sent.

The problem is as i just mentioned above,how just i can select email from finance department only for example?

Maybe you have any idea for my problem encountered..[/quote]
You forgot $dept = $this->input->post('dept');




Theme © iAndrew 2016 - Forum software by © MyBB