Wednesday, November 6

Send Outlook Email (with text formatting) using QTP

Hello Friends!!

In this post we will quickly see how to send an outlook email.
I know, most of you all know how to send email using QTP, then why this post??

Well, here we will see how to use HTML code to format your email's body i.e. text style, font color, formatting etc. Here we go!!

Dim oOutlook, oEmail, vEmailTo, vEmailCC, vEmailBCC

vEmailTo = ""    'replace  this with your email id
vEmailCC = ""
vEmailBCC = ""
vEmailSubject = "Test Email from"

Set oOutlook = CreateObject("Outlook.Application")
Set oEmail = oOutlook.CreateItem(0)

oEmail.To = vEmailTo
oEmail.CC = vEmailCC
oEmail.BCC = vEmailBCC
oEmail.Subject = vEmailSubject

oEmail.HTMLBody = "<HTML>"&_
"<p Style=""background-color:red""><b>This text is bold and red background</b></p>"&_
"<p><strong>This text is strong</strong></p>"&_
"<p><em>This text is emphasized</em></p>"&_
"<p><Font color=""green""<i>This text is green and italic</Font></i></p>"&_
"<p><Font color=""red"" size = 16><small>This text is red and big!</small></Font></p>"&_
"<p>This is<sub> subscript</sub> and <sup>superscript</sup></p>"&_

wait 2
wait 2

Set oEmail = Nothing
Set oOutlook = Nothing

'For more details on HTML code, please visit

In case of any queries, please post your comments. Happy QTPing!!


  1. This comment has been removed by a blog administrator.

  2. Hi abhihshek,
    Thank you the for code.
    but want to type three line in outlook using for loop
    for example

    Test Set -1
    Total Passed =20
    Total Failed = 3

    Test Set -2
    Total Passed =21
    Total Failed = 2

    Test Set -3
    Total Passed =29
    Total Failed = 2

    .. like this for all the test set executed.
    could you please help with the code or an idea so that i can implement in my driver script.

    Thanks In Advance.
    Gautam Grover

  3. Many a times, important documents are shared through emails. In that case email document management becomes a requirement. Not to worry as Grexit makes email document management fast and easy. Grexit brings to you a secured way of email storage and customer email management.

  4. I appreciated your work very thanks

  5. This comment has been removed by the author.

  6. Utilizing 'Viewpoint Connector,' booked to be accessible worldwide in the not so distant future in 11 dialects, buyers can see and deal with their records from Outlook for nothing, with full contact, email, and email envelope synchronization. iniciar sesion hotmail

  7. Useful post, thanks! I want to recommend one great tool that reveals personal emails and phone numbers from social networks: — check it out!find email from linkedin