How to send simple mail from windows form....

Posted on 2008-11-19
Last Modified: 2013-12-17

I want to send a simple mail from my windows app using Outlook.Application but the outlook app will not start ???

Can somone show me how i can send a simple mail from windows form by using outlook
private void SendTransactionByEmail()


            Microsoft.Office.Interop.Outlook.Application outLookApp = new Microsoft.Office.Interop.Outlook.Application();

            // Create the mail message

            Microsoft.Office.Interop.Outlook.MailItem mailItem = (MailItem)outLookApp.CreateItem(OlItemType.olMailItem);

            mailItem.Subject = "some subject goes here";

            mailItem.BodyFormat = OlBodyFormat.olFormatHTML;

            mailItem.Body = "email body goes here"; 



Open in new window

Question by:Adnan

    Author Comment

    i want to Open outlook message window...?!

    Accepted Solution

    I MADE IT....

    You can open the outlook window by this code...

    Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
                Microsoft.Office.Interop.Outlook.MailItem oMsg = (MailItem)oApp.CreateItem(OlItemType.olMailItem);
                    Microsoft.Office.Interop.Outlook.Recipient oRecip;

                    //Then for every recipient you want to add:

                    oRecip = (Microsoft.Office.Interop.Outlook.Recipient)oMsg.Recipients.Add("");

                    //Then use this call to display the message window:

                    //Finally, remember to set all objects to null once you are done:

                    oRecip = null;
                    oMsg = null;
                    oApp = null;

    Expert Comment

    thanks for the post, i modified the code to work for me in Visual Basic .NET, e.g. :
        Private oApp As New Microsoft.Office.Interop.Outlook.Application
        Private oMsg As Microsoft.Office.Interop.Outlook.MailItem
        Private oRecip As Microsoft.Office.Interop.Outlook.Recipient
        Private Sub PrePrepareEmail()
            oMsg = oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
            oRecip = oMsg.Recipients.Add("")
        End Sub
        Private Sub WheneverLater()
            oApp = Nothing
            oMsg = Nothing
            oRecip = Nothing
        End Sub

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Live - One-on-One C# Help from Top Experts

    Solve your toughest problems, fast.
    C# experts are online now and ready to help you.

    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now