Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Create exchnage task
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Lorenzo Soncini  
View profile  
 More options Sep 27 2005, 8:15 am
Newsgroups: microsoft.public.exchange.development
From: "Lorenzo Soncini" <lorenzo.sonc...@technoservice.com>
Date: Tue, 27 Sep 2005 14:15:14 +0200
Local: Tues, Sep 27 2005 8:15 am
Subject: Create exchnage task
Hy,
how can I create a task in a public folder using .NET ?

Lorenzo Soncini


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Glen Scales [MVP]  
View profile  
 More options Sep 28 2005, 8:37 pm
Newsgroups: microsoft.public.exchange.development
From: "Glen Scales [MVP]" <gsca...@outlookexchange.com>
Date: Thu, 29 Sep 2005 10:37:43 +1000
Local: Wed, Sep 28 2005 8:37 pm
Subject: Re: Create exchnage task
There are two methods you could use both are kind of work arounds because
none of the current Exchange API's really support task. If you can run your
code locally then you could create interop dlls for CDOEX and ADODB then use
Exoledb to create the tasks. Otherwise you can use the native .NET classes
and use WebDAV to create the tasks which will work remotely. Eg something
like this should work (this is base on a SDK sample for creating
appointments via webdav
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/e2k3...)

  {
   // Variables.
   string strExchSvrName = "";
   string strMailbox = "";
   string strTaskUri = "";
   string strTaskItem = "";
   string strDomain = "";
   string strUserName = "";
   string strPassword = "";
   string strApptRequest = "";
   string strMailInfo = "";
   string strTaskInfo = "";
   string strXMLNSInfo = "";
   string strHeaderInfo = "";
   System.Net.HttpWebRequest PROPPATCHRequest = null;
   System.Net.WebResponse PROPPATCHResponse = null;
   System.Net.CredentialCache MyCredentialCache = null;
   byte[] bytes = null;
   System.IO.Stream PROPPATCHRequestStream = null;

   try
   {
    strExchSvrName = "servername";
    strMailbox = "mailbox";
    strTaskItem = "testtask.eml";
    strTaskUri = "http://" + strExchSvrName + "/exchange/"
     + strMailbox + "/tasks/";

    // User name and password of appointment creator.
    strUserName = "user";
    strDomain = "domain";
    strPassword = "password";

    // XML namespace info for the WebDAV request.
    strXMLNSInfo = "xmlns:g=\"DAV:\" "
     + "xmlns:e=\"http://schemas.microsoft.com/exchange/\" "
     + "xmlns:mapi=\"http://schemas.microsoft.com/mapi/\" "
     + "xmlns:mapit=\"http://schemas.microsoft.com/mapi/proptag/\" "
     + "xmlns:dt=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\" "
     +
"xmlns:h=\"http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/\"
"
        +
"xmlns:i=\"http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/\"
"
     + "xmlns:header=\"urn:schemas:mailheader:\" "
     + "xmlns:mail=\"urn:schemas:httpmail:\"";

    strTaskInfo =  "<h:0x00008104
dt:dt=\"dateTime.tz\">2005-09-29T00:00:00Z</h:0x00008104>"
        + "<h:0x00008105
dt:dt=\"dateTime.tz\">2005-09-29T00:00:00Z</h:0x00008105>"
     + "<h:0x0000811C dt:dt=\"boolean\">0</h:0x0000811C>"
     + "<h:0x00008101 dt:dt=\"int\">0</h:0x00008101>"
     + "<h:0x00008102 dt:dt=\"float\">0</h:0x00008102>"
     + "<i:0x00008503 dt:dt=\"boolean\">1</i:0x00008503>";

       strHeaderInfo = "<header:to>" + strMailbox + "</header:to>";
    strMailInfo = "<mail:subject>Test Task Subject</mail:subject>"
     + "<mail:htmldescription>Test Description</mail:htmldescription>";

    // Build the XML body of the PROPPATCH request.
    strApptRequest = "<?xml version=\"1.0\"?>"
     + "<g:propertyupdate " + strXMLNSInfo + ">"
     + "<g:set><g:prop>"
     + "<g:contentclass>urn:content-classes:task</g:contentclass>"
     + "<e:outlookmessageclass>IPM.Task</e:outlookmessageclass>"
     + strMailInfo
     + strTaskInfo
     + strHeaderInfo
     + "</g:prop></g:set>"
     + "</g:propertyupdate>";
    MyCredentialCache = new System.Net.CredentialCache();
    MyCredentialCache.Add( new System.Uri(strTaskUri),
     "NTLM",
     new System.Net.NetworkCredential(strUserName, strPassword, strDomain)
     );
    PROPPATCHRequest =
(System.Net.HttpWebRequest)HttpWebRequest.Create(strTaskUri + strTaskItem);
    PROPPATCHRequest.Credentials = MyCredentialCache;
    PROPPATCHRequest.Method = "PROPPATCH";
    bytes = Encoding.UTF8.GetBytes((string)strApptRequest);
    PROPPATCHRequest.ContentLength = bytes.Length;
    PROPPATCHRequestStream = PROPPATCHRequest.GetRequestStream();
    PROPPATCHRequestStream.Write(bytes, 0, bytes.Length);
    PROPPATCHRequestStream.Close();
    PROPPATCHRequest.ContentType = "text/xml";
    PROPPATCHResponse =
(System.Net.HttpWebResponse)PROPPATCHRequest.GetResponse();
    PROPPATCHResponse.Close();

    Console.WriteLine("Task successfully created.");

   }
   catch(Exception ex)
   {
     Console.WriteLine(ex.Message);
   }

  }

Cheers
Glen

"Lorenzo Soncini" <lorenzo.sonc...@technoservice.com> wrote in message

news:Or0af01wFHA.3860@TK2MSFTNGP09.phx.gbl...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alex  
View profile  
 More options Sep 29 2005, 10:40 am
Newsgroups: microsoft.public.exchange.development
From: "Alex" <Alex.A...@newsgroups.nospam>
Date: Thu, 29 Sep 2005 10:40:58 -0400
Local: Thurs, Sep 29 2005 10:40 am
Subject: Re: Create exchnage task
Glen,
Maybe I am missing something, but why not look the OOM?
Try this code:

{
      Outlook.ApplicationClass oApp = new Outlook.ApplicationClass();
      Outlook.NameSpace oNS = oApp.GetNamespace( "MAPI" );
      Outlook.MAPIFolder oFolder = oNS.GetDefaultFolder(
Outlook.OlDefaultFolders.olPublicFoldersAllPublicFolders );
      Outlook.MAPIFolder oPublicTaskFolder = oFolder.Items.Item(
"MyPublicTaskFolder" );
      Outlook._Items oItems = oPublicTaskFolder.Items;
      Outlook._TaskItem oTask = (Outlook._TaskItem) oItems.Add(
"IPM.Task" );
      oTask.Subject = "My Subject";
      oTask.Body = "Notes and other text go here";
      oTask.StartDAte = DateTime.Now;
      oTask.DueDate = DateTime.Now.AddDays(7); //Due a week from now
      oTask.Save();

    // et voila!
    // now clean up and you're set to go.
    oTask = null;
    oApp = null;

    GC.WaitForPendingFinalizers();
    GC.Collect();

}

You'd need to add Outlook to your references.

Alex

"Glen Scales [MVP]" <gsca...@outlookexchange.com> wrote in message
news:eRfaF4IxFHA.3720@TK2MSFTNGP11.phx.gbl...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Glen Scales [MVP]  
View profile  
 More options Sep 29 2005, 6:29 pm
Newsgroups: microsoft.public.exchange.development
From: "Glen Scales [MVP]" <gsca...@outlookexchange.com>
Date: Fri, 30 Sep 2005 08:29:06 +1000
Local: Thurs, Sep 29 2005 6:29 pm
Subject: Re: Create exchnage task
Nice code thanks for sharing that's a good point OOM is the only currently
supported API that allows you to create tasks. The main problem with OOM
however is that its not suitable for use in Automation code so its not a
good choice if you want to use it say in a ASP.NET application.But if you
dont have those problems its a good choice.

Cheers
Glen

"Alex" <Alex.A...@newsgroups.nospam> wrote in message

news:eaSIPPQxFHA.2620@TK2MSFTNGP09.phx.gbl...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alex  
View profile  
 More options Sep 30 2005, 9:32 am
Newsgroups: microsoft.public.exchange.development
From: "Alex" <Alex.A...@newsgroups.nospam>
Date: Fri, 30 Sep 2005 09:32:17 -0400
Local: Fri, Sep 30 2005 9:32 am
Subject: Re: Create exchnage task
I see. Well, I have a winform App, in C#... and this code works fine for me.
One thing I am trying to get that is the Contacts selected by the user.
For some reason OOM exposes both Contats and ContactNames as string, but
when I look at Contacts property is gives me gibberish... I am guessing it
should be a collection of sorts..

Alex

"Glen Scales [MVP]" <gsca...@outlookexchange.com> wrote in message
news:upwS3UUxFHA.1148@TK2MSFTNGP11.phx.gbl...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »