Email import

Wondering if anyone has implemented something to handle incoming mail / response to outbound mail from SC? For example:

  1. the system sends an email including a comment to ‘respond above this line’
  2. The person who received the email responds to the email (above that line on the email)
  3. The response is imported into the system as a comment on the original message

I have a workable solution for points 1 and 2.
However, I use phpMailer.
Unfortunately for point 3, I don’t know how to help.
If the phpMailer solution suits you, I’ll post the code here.

you can use the code below to search for emails stored in $mail_to_mail

// Check for record
$check_sql1 = ‘SELECT DISTINCT email’
. ’ FROM sec_users’
. ’ INNER JOIN bpv_pok_opgeleverd ON sec_users.st_id = bpv_pok_opgeleverd.bpv_beg_school’
. " WHERE bpv_pok_opgeleverd.loc_id = ‘" . [usr_loc_id] . "’ AND bpv_pok_opgeleverd.bpv_afgerond = ‘4’";

sc_select(rs, $check_sql1);

$arr = array($rs);

//verzamelen van de mailadressen
{field_total} = 0;
if (false == {rs}) // Error while accessing database
{
sc_error_message(‘Error while accessing database.’);
}
else
{
while(!$rs->EOF)
{
foreach({rs} as $value)
$mail_to_mail[] = $value[0];
$mail_to_mail = implode(’; ', $mail_to_mail);
}
$rs->Close();
}

you can use the code below to send the mail

[usr_login] is the user who send the mail

/**

  • Send a simple email
    */

// Email parameters
$mail_smtp_server = [smtp_server_brixx]; // SMTP server name or IP address
$mail_smtp_user = [smtp_user_brixx]; // SMTP user name
$mail_smtp_pass = [smtp_pass_brixx]; // SMTP password
$mail_from = [smtp_from_brixx]; // From email
$mail_to = [usr_login]; // To email
$mail_message = $bericht;
$mail_subject = 'BRIXX BPV Mededeling: ’ . {subject} . ‘’; // Message body
$mail_format = ‘H’; // Message format: (T)ext or (H)tml
$mail_copies = $mail_to_mail; // List of the emails that will recieve the message
$mail_tp_copies = ‘BCC’; // Type copies: BCC (Hiden copies) or CCC (Regular copies)
$mail_port = ‘2525’; // Server port
$mail_tp_connection = ‘N’; // Connection security (S) or (N)

  1. if you let the use the mailadres outside scriptcase i have no answer to this

I am doing #1 & #2#3 is where I have trouble figuring it out. Thank you.

You would need to have a CRON job or something similar setup on your server to check the mailbox on a regular basis.
you could do something like this to pull the body and subject

$mail->Subject = $subj;
$mail->Body = $message;

and then depending on your database and forms you can you that information to add the response to your system.
If you can share some of your database information i might be able to give a more detailed example.

Thanks

Keith

I did not have much luck with incoming mail with just scriptcase. Last year i was working on a project that needed the same function. I came across a windows application that would go out and fetch the mail and pars the data out into my database. Then i used scriptcase to fulfill the rest of my application. It work fairly good. the support was top notch too. here is the url. I am not a distributor just what i came across when trying to do the same thing you are for step #3. https://www.emailparser.com/