def dict_to_html_table(a_dict):
    """
    Converts a dictionary to a HTML table. Keys become the header of the table.
    Useful while sending email from the code

    :param dict a_dict: key value pairs in the form of a dictionary

    :return: HTML table representation corresponding to the values in the dictionary
    :rtype: str
    """
    body = ""
    keys = sorted(a_dict.keys())
    for key in keys:
        body += "<tr><th>%s</th><td>%s</td></tr>\n" % (str(key), str(a_dict[key]))
    return "<table>%s</table>" % body