Something like this at the start
$command='insert into mailstore.received (SenderName,SenderEmailAddres
+s,SentOnBehalfOfName,ReplyRecipientNames,SenderEmailType,SentOn,Recei
+vedTime,MessageClass,Size,Subj,SentTo,Unread,InternetCodepage,importa
+nce,EntryID,ConversationIndex,ConversationTopic,Class,BodyFormat,Body
+) values (?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?)';
$sth=$dbh->prepare($command);
and in the loop
@values= map $msg->{$_}, qw{SenderName SenderEmailAddress SentOnBehalf
+OfName ReplyRecipientNames SenderEmailType SentOn ReceivedTime Messag
+eClass Size Subj SentTo Unread InternetCodepage importance EntryID Co
+nversationIndex ConversationTopic Class BodyFormat Body} ;
$rv=$sth->execute(@values);
UnderMine