Blue Theme Orange Theme Green Theme Red Theme
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Home | Forums | Videos | Photos | Blogs | Beginners | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
6 Months Free & No Setup Fees ASP.NET Hosting!
Search :       Advanced Search »
Home » VB.NET » Creating a Task in Outlook

Creating a Task in Outlook

This article helps us to create a new task in Microsoft Outlook and send it through a mail.

Page Views : 16182
Downloads : 0
Rating :
 Rate it
Level : Beginner
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 

The following steps will help us to create the application.

  1. Start Microsoft Visual Studio .NET.
  2. On the File menu, click New, and then click Project.
  3. Click Visual Basic Projects under Project Types, and then click Console Application under Templates. By default, Module1.vb is created.
  4. Add a reference to the Microsoft Outlook 10.0/11.0 Object Library. To do this, follow these steps:
  • On the Project menu, click Add Reference.
  • On the COM tab, click Microsoft Outlook 10.0 Object Library, and then click Select.
  • Click OK in the Add References dialog box to accept your selections. If you are prompted to generate wrappers for the library that you selected, click Yes.

    5.  In the Code window, replace all of the code with the following:

Imports System.Reflection

Module Module1

    Sub Main()

        Try

 

            ' Create an Outlook application.

            Dim oApp As Outlook.Application = New Outlook.Application()

 

            ' Get NameSpace and Logon.

            Dim oNS As Outlook.NameSpace = oApp.GetNamespace("mapi") oNS.Logon("Outlook", Missing.Value, False, True)

 

            ' TODO: ' Create a new TaskItem.

            Dim OTask As Outlook.TaskItem = App.CreateItem(Outlook.OlItemType.olTaskItem)

 

            ' Assign the task

            OTask.Assign()

 

            ' Add recipients to the task

            OTask.Recipients.Add("sridhar@yahoo.com")

 

            ' Add the subject to the task

            OTask.Subject = "testing for SFA using code"

 

            'Add the body to the task

            OTask.Body = "tested by sridhar using code"

 

            ' Add the Task duedate

            OTask.DueDate = DateTime.Today

 

            ' Set the reminder to the task

            'oAppt1.ReminderSet = True

 

            ' Set the reminder time

            OTask.ReminderTime = OTask.DueDate

 

            ' If you want to display the task uncomment the next line

            'oAppt1.Display(True)

 

            ' Save the task to outlook

            OTask.Save()

 

            ' Send the task

            'oAppt1.Send()

 

        Catch ex As Exception

 

            Console.WriteLine(ex.Message)

 

        Finally

            ' Log off.

            oNS.Logoff()

 

            ' Clean up.

            oApp = Nothing

            oNS = Nothing

        End Try

    End Sub

 

End Module


    6.  Press F5 to build and run the program.
    7.  Verify that the appointment is created

Conclusion

The tasks have been now created and send through the mail using the Outlook and similarly various task/actions can be done using the Outlook dll and it can be said in the next article.

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
Sridhar Manoharan
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Discover the top 5 tips for understanding .NET
Ricky Leeks presents the top 5 tips for understanding .NET Interoperability. Learn more.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
 Comments
Thanks by Terry On February 18, 2009
Thanks Sridhar, your article helped me in adding tasks in outlook via my VB.NET application. After adding the task, when I open my outlook, I can see the created task in ToDo, Task List & in Say & Week of Calendar but not in Month of Calendar View. Any idea how can I see the task in Month view too. And on mouse over of the task, I want to see the body of the task in a window, like we can see the Start Time, End Time, etc .I want to see the body part of the task. How Can I see that full contents. If you have any idea to solve any or my both points, would be greatful. Thanks Once again.
Reply | Email | Modify 
Great article! by John On November 24, 2009
This is a great article!  Thanks!

I have one question though:  How do I save a task to a users task list without them having to accept it in exchange?  This is part of an automated process which assings tasks to users depending on the certain project creations.

Do I need to provide the exchange admin credentials?  Do I do this in this snippet?

oNS.Logon("Outlook", Missing.Value, false, true); --> oNS.Logon("adm_id", "adm_pwd", false, true);

Reply | Email | Modify 
6 Months Free & No Setup Fees ASP.NET Hosting!
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.