diff --git a/process/Bulkmail_lib/process.js b/process/Bulkmail_lib/process.js
index d40a686b69e08ec04ca93a254ba35a475854c2b8..b919ed14e3a877f651b6b3a4067ea04e3aa4dd15 100644
--- a/process/Bulkmail_lib/process.js
+++ b/process/Bulkmail_lib/process.js
@@ -234,6 +234,7 @@ BulkMailUtils.sendBulkMail = function (pBulkMailId, pIsTestRun)
             let isSuccess = false;
             let contactId = recipientData[i]["CONTACT_ID"];
             let email = mails[contactId];
+            let currentMailLogId = mailLogIds.get(contactId);
 
             if (email !== undefined)
             {
@@ -244,15 +245,28 @@ BulkMailUtils.sendBulkMail = function (pBulkMailId, pIsTestRun)
                     if(testRecipientData[j][1])
                     {
                         email.toRecipients = [testRecipientData[j][1]];
+                        let nextMailLogId = util.getNewUUID();
+                        email.body = email.body.replace(currentMailLogId,nextMailLogId);
+                        currentMailLogId = nextMailLogId;
                         isSuccess = email.send();
 
                         Array.prototype.push.call(isSuccess ? successIds : failedIds, recipientData[i]["BULKMAILRECIPIENTID"]);
 
                         if (testRecipientData[j][0])
                         {
-                            let mailLogId = util.getNewUUID();
-                            db.insertData("MAIL_LOG", ["MAIL_LOGID","MAIL_RUN_ID","CONTACT_ID","STATUS","SENDER_EMAIL","RECIPIENT_EMAIL","MAILING_SUBJECT","DATE_SEND"], null, [mailLogId,mailrunId,testRecipientData[j][0],(isSuccess ?$KeywordRegistry.bulkMailRecipientStatus$sent(): $KeywordRegistry.bulkMailRecipientStatus$failed()),emailSender,testRecipientData[j][1],email.subject,vars.get("$sys.date")]);
-                            this.storeEmlFile(pBulkMailId, mailrunId, mailLogId,email.getEML());
+                            new SqlBuilder()
+                            .tableName("MAIL_LOG")
+                            .insertFields({
+                                "MAIL_LOGID":nextMailLogId,
+                                "MAIL_RUN_ID":mailrunId,
+                                "CONTACT_ID":testRecipientData[j][0],
+                                "STATUS":(isSuccess ?$KeywordRegistry.bulkMailRecipientStatus$sent(): $KeywordRegistry.bulkMailRecipientStatus$failed()),
+                                "SENDER_EMAIL":emailSender,
+                                "RECIPIENT_EMAIL":testRecipientData[j][1],
+                                "MAILING_SUBJECT":email.subject,
+                                "DATE_SEND":vars.get("$sys.date")
+                            });
+                            this.storeEmlFile(pBulkMailId, mailrunId, nextMailLogId,email.getEML());
                         }
                     }
                 }