Send Notification to users with username and password I have imported a set of user information into drupal website and all the users are active. 

Now I need to generate the password for each user and send an email to them to notify them that the account has been created.

I found the code here which shows how to update the password of the user by code.

$account = user_load(array('uid' =&gt; $userdata['uid']));
$password = user_password();
$username = $userdata['username'];
$updates = array(
  'pass' =&gt; $password,
   'roles' =&gt; array(
    &lt;rid&gt; =&gt; '&lt;role title&gt;';
 ),
);

user_save($account, $updates);


Now how can I notify the users of their new username and password.
You can notify your user by mail using drupal_mail either at the time of updating your password. You arrange your username/password in some template using HTML &amp; send that by help of the above given function drupal_mail.
I hope this help. Let me know if do..