Library tutorials & articles

How to access Outlook and post to a blog using C#

Page 3 of 3
  1. Introduction
  2. Posting to your blog
  3. Accessing the web service

Accessing the web service

Once the web service is up and working, you need to create a web reference to the webservice, this is done in Visual Studio by right clicking the references box and choosing add web reference.  Lets say there's one at http://webservices.nullify.net/blog.asmx

When you add a web reference Visual Studio will automatically produce a wrapping class that will allow you to easily instantiate the web service as a local object, without worrying about any of the underlying technology.  (I'll only cover synchronous calls here, otherwise this will turn into a full fledged book...)

To access the above web service, you would simply define it as a new object:

net.nullify.webservices.Blog blog = new net.nullify.webservices.Blog();

And you would define our NewsItem scructure that we defined in the webservice:

net.nullify.webservices.NewsItem article = new net.nullify.webservices.NewsItem();

This will allow you to now call methods of the blog object, which will execute directly on your web server, with all the rights of a normal ASP.NET page - including the ability to insert articles into your database!

Using our imaginary webservice, rather than writing the subject for each MailItem to the console, you can post them to your blog. So, going back to our original loop that went through all the mail items in a particular Outlook folder:

foreach(Outlook.MailItem t in inboxFld.Items)
{
  article.subject = t.Subject;
   article.content = t.Body;
   article.topic = "OutlookPost";
   blog.AddArticle(article);
}

(Note, this is assuming your webservice has no security, or is protected by ASP.NET/IIS' own security!)

I hope this post helps someone!

Comments

  1. 05 Sep 2007 at 07:50

    I am working for fetching contacts from outlook express. I have explored a lot , But I couldn't .

    How can I get access microsoft outlook express's  conatacts?

    Is this possible?

     

  2. 05 Mar 2005 at 16:17

    Hii Friends,


    This is kumar, I facing the following problm. If Any body knows the solution please pass the  solution to my E-Mail Id.


    Query:          How To Dynamically Pass The .aspx Page Values Into an .Html Page In ASP.NET + C#. Here I am Passing more than one value. I dont want to write hard code.


    Query:         I am writing the code for getting the data from database. In this data i have images. Then i have to pass these images to web page. Its like a banner Engine. But, Here i dont wont to take a "adrotator". I had taken a Html Iframe control. Then I have to pass the image name throuth src. Then i had verified and got the required images through database comparisons. When i run the application i have to display the web like "http://wepage1.aspx/sample.html". In this sample.html page is the dynamic page. When u run the web page ".aspx" that time i need to display/ pass these wepage image values to .html(sample.html) page.
                   How this is possible? If anybody knows the solution please pass the solution to my ID


    Thnx and Regards
    Naresh Kumar
    ravuri_naresh@yahoo.co.in  

  3. 12 Feb 2005 at 12:13


    hello,




    I want somre help from u.we are using  check boxes in datagrid for activating and deactivating.how to put that
    check boxes in datagrid and reflect changes in database


                                                                                  thank you,
                                                                MohanVarma.

  4. 01 Jan 1999 at 00:00

    This thread is for discussions of How to access Outlook and post to a blog using C#.

Leave a comment

Sign in or Join us (it's free).

AddThis

Related discussion

Related podcasts

  • Looking into the C# Crystal Ball with Charlie Calvert and Bill Wagner

    One of the most exciting announcements from PDC was the news about C# 4.0 and Visual Studio 2010. With all the excitement and discussion throughout the event about these new developer tools, we reached out to two experts in the fields. Charlie Calvert and Bill Wagner sat down with Keith and Woody...

Events coming up

  • Dec 6

    Developing AJAX Web Applications with Castle Monorail

    London, United Kingdom

    Monorail is the model-view-controller engine of the Castle Project, bringing many of the best ideas of Ruby on Rails to the .NET world. In this talk, David De Florinier and Gojko Adzic show how Monorail makes it easy to develop .NET based AJAX applications, and how to use the Castle Project to build Web 2.0 applications effectively. Come to this session if you are a .NET web developer. Everyone is welcome!