Send email using ms-outlook

This code shows how to send email using MS-Outlook.You need to add reference of Microsoft Outlook 12.0 Object Library in your project .i.e. Interop.Microsoft.Office.Core.dll, Interop.Microsoft.Office.Interop.Outlook.dll and Interop.Outlook.dll should be included in the bin directory.The dll's are present in the attachment. Also MS-Outlook 2003 or higher version should be installed on the pc where the code executes.

'Create the object of ms-outlook.
Dim objOutlookApp As New Outlook.Application
Dim objMail As Outlook._MailItem

objMail = objOutlookApp.CreateItem(Outlook.OlItemType.olMailItem)
objMail.BodyFormat = Outlook.OlBodyFormat.olFormatHTML
'Subject of the mail
objMail.Subject = "Test mail"
'Content of the mail
objMail.HTMLBody = "This is test mail"
'The target mail id.
objMail.To = ""
'The person receving this mail should not send receipt
'about receiving the mail.For this ReadReceiptRequested
'is set to false.
objMail.ReadReceiptRequested = False
'Send the mail.
'Destroy the object of the mail.
objMail = Nothing


  • Dll's (
  • Comments

    Author: PHANI HARSHITHA MADALA03 Feb 2010 Member Level: Gold   Points : 1

    Hi Mr.programmer,

    Very usefull info..

    Thanks for sharing with all of us.



    Author: Dilip10 Feb 2010 Member Level: Gold   Points : 0

    Thanks Harshitha

    Author: Er. Ram Singh06 Sep 2010 Member Level: Gold   Points : 2

    using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Net.Mail;public partial class Default : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) {//Calling the function SendMail Response.Write( SendMail("","","","Test Mail","Test Mail Body")); } public string SendMail(string toList, string from, string ccList, string subject, string body) { MailMessage message = new MailMessage(); SmtpClient smtpClient = new SmtpClient(); string msg = string.Empty; try { MailAddress fromAddress = new MailAddress(from); message.From = fromAddress; message.To.Add(toList); if (ccList != null && ccList != string.Empty) message.CC.Add(ccList); message.Subject = subject; message.IsBodyHtml = true; message.Body = body; smtpClient.Host = ""; smtpClient.Port = 25; smtpClient.UseDefaultCredentials = true; smtpClient.Credentials = new System.Net.NetworkCredential("", "password"); smtpClient.Send(message); msg = "Successful"; } catch (Exception ex) { msg = ex.Message; } return msg; }}

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: