Friday, January 27, 2012

Send Mail To, CC, BCC









Transform in SendMail Component :


include  "~$AB_HOME/include/mail.dml";
/*Prepare message information*/
message::prepare_message(in) =
begin
  let string("\x01") from = read_file("${MAILFROM}");
  let string("\x01") reply_to = read_file("${MAILREPLYTO}");
  let string("\x01") to_list_file = read_file("${MAILTO}");
  let string("\x01") cc_list_file = read_file("${MAILCC}");
  let string("\x01") bcc_list_file = read_file("${MAILBCC}");
  let string("\x01")[] from_tmp_vect = string_split(from,";");
  let string("\x01")[] reply_tmp_vect = string_split(reply_to,";");
  let string("\x01")[] to_tmp_vect = string_split(to_list_file,";");
  let string("\x01")[] cc_tmp_vect = string_split(cc_list_file,";");
  let string("\x01")[] bcc_tmp_vect = string_split(bcc_list_file,";");
  let string("\x01")[] tmp_split;
  let int i = 0;
 
  let record
    string("\x01") readable_name = NULL;
    string("\x01") e_mail_address = NULL;
  end[length_of(from_tmp_vect)] user_from_mail = allocate();
 
  let record
    string("\x01") readable_name = NULL;
    string("\x01") e_mail_address = NULL;
  end[length_of(reply_tmp_vect)] user_reply_mail = allocate();
 
  let record
    string("\x01") readable_name = NULL;
    string("\x01") e_mail_address = NULL;
  end[length_of(to_tmp_vect)] user_to_mail = allocate();
 
  let record
    string("\x01") readable_name = "";
    string("\x01") e_mail_address = "";
  end[length_of(cc_tmp_vect)] user_cc_mail = allocate();
 
  let record
    string("\x01") readable_name = NULL;
    string("\x01") e_mail_address = NULL;
  end[length_of(bcc_tmp_vect)] user_bcc_mail = allocate();
   
  i = 0; 
  for (i, i <= length_of(from_tmp_vect)-1)
  begin
    tmp_split = string_split(from_tmp_vect[i],",");
    user_from_mail[i].readable_name = tmp_split[0];
    user_from_mail[i].e_mail_address = tmp_split[1];
  end;
 
  i = 0; 
  for (i, i <= length_of(reply_tmp_vect)-1)
  begin
    tmp_split = string_split(reply_tmp_vect[i],",");
    user_reply_mail[i].readable_name = tmp_split[0];
    user_reply_mail[i].e_mail_address = tmp_split[1];
  end;
 
  i = 0; 
  for (i, i <= length_of(to_tmp_vect)-1)
  begin
    tmp_split = string_split(to_tmp_vect[i],",");
    user_to_mail[i].readable_name = tmp_split[0];
    user_to_mail[i].e_mail_address = tmp_split[1];
  end;
 
  i = 0; 
  for (i, i <= length_of(cc_tmp_vect)-1)
  begin
    tmp_split = string_split(cc_tmp_vect[i],",");
    user_cc_mail[i].readable_name = tmp_split[0];
    user_cc_mail[i].e_mail_address = tmp_split[1];
  end;
 
  i = 0; 
  for (i, i <= length_of(bcc_tmp_vect)-1)
  begin
    tmp_split = string_split(cc_tmp_vect[i],",");
    user_bcc_mail[i].readable_name = tmp_split[0];
    user_bcc_mail[i].e_mail_address = tmp_split[1];
  end;
  
  message::[record
  envelope [record
             return_path  user_from_mail
             created_date local_now()
             from         user_from_mail
             sender NULL
             reply_to     user_reply_mail
             subject      in.subject
             to           user_to_mail
             cc           user_cc_mail
             bcc          user_bcc_mail
             in_reply_to ""
             message_id ""]
  content [record
             header [record
                       mime_type "text"
                       mime_subtype "plain"
                       parameters [vector]
                       encoding "q"
                       id ""
                       description U""
                       disposition [record
                                      disp_type ""
                                      parameters [vector]]
                       language [vector]
                       location ""]
             text in.text
             parts NULL]]
;
end;
type _message_t=record
  envelope_t envelope;
  content_t content=NULL;
end; /*Metadata for records containing message information*/
type _server_log_t=string('\0'); /*Metadata for records containing server_log information*/
out :: create_output(in, server_log) =
begin
end;

=======================

TextFile for list distribution:

Nama Lengkap,email_saya@hostname.com;Indra Gunawan,indra.stone@gmail.com


No comments: