$imapp = Mail::IMAPClient->new( Server => 'servername, User => 'userid', Password => 'password', Uid => 1, Debug => 0 ); $tempuid = $imapp->append_string("Sent Items", $messagestring ,"\\Seen"); $tempuidarray->[0] = $tempuid; $imapp->set_flag("\Seen",$tempuidarray); if(!$tempuid){warn "ERROR saving to sent items: $@\n"; }