Exchange Server Posting issue through webdav (Full Version)

All Forums >> [Microsoft Exchange 2003] >> Exchange 2003 SBS



Message


ganeshgopug -> Exchange Server Posting issue through webdav (5.Jul.2006 9:53:52 AM)

Hi I am using Exchange Server Version: 6.5.6944.0. I am using ASP.Net to send Meeting request with Recurrence patern using WEBDAV. Eventhouhg it is working fine, I am getting some more trouble with some conditions. I have listed the conditions below. Could anyone suggest me how to proceed?

1) When send the Reccurrence meeting more than one month, then the organizer's calendar is updated for one month only. But when the attendee accept the request, then his calendar is updated with full recurrence (more than one month if it is).

2) The attendees who are using outlook instead of webaccess, having only one instance (first instance) of my recurrence meeting in their calendar.

Here I have pasted my code...

Public Sub SendMeetingRequest(ByVal Fromdt As DateTime, ByVal Todt As DateTime, ByVal l_user As String, ByVal l_attendees As String, ByVal L_Body As String, ByVal l_sno As String, ByVal location As String, ByVal MailSub As String, Optional ByVal Opt_attendees As String = "")
            ' Variables
          Dim strMtgUri, strMtgRequestUri, strExchSvrName As String
          Dim strMailbox, str_exchange_srv, strReqAttendees, strMtgResources As String
          Dim strOptAttendees, strUserName, strPassWord As String
          Dim strMtgRequest, strCalInfo, strHeaderInfo As String
          Dim strMailInfo, strXMLNSInfo, strSubmissionUri As String
          Dim bResult As Boolean
          Dim strUID, strCCInfo, strMapiInfo As String
          Dim Fms_Obj As New FMS.Database
          Dim MyCredentialCache As System.Net.CredentialCache
          Dim F_Name, Name As String
          Dim pos As Byte
          ' Exchange server name.
          strExchSvrName = L_ExIP
          ' Mailbox folder of the meeting organizer.
          strMailbox = "abc@mail.com "
          pos = InStr(1, strMailbox, "@") - 1
          strMailbox = Left(strMailbox, pos)
          'strMailbox = "user1@example.com"
          If Not Fms_Obj Is Nothing Then Fms_Obj.Close()

          ' Required meeting attendees.
          strReqAttendees = l_attendees
          ' Optional meeting attendees.
          strOptAttendees = Opt_attendees
          ' Meeting resources
          strMtgResources = location
          ' Username and password of meeting creator.
          strUserName = L_ExDomain & "\" & L_ExUser
          strPassWord = L_ExPwd

          ' URI of the meeting item.
          strMtgUri = "http://" & strExchSvrName & "/exchange/" & _
      strMailbox & "/Calendar/"
          ' URI of the meeting request item.
          strMtgRequestUri = "http://" & strExchSvrName & "/exchange/" & _
        strMailbox & "/Calendar/ORS_" & l_sno & "_meetingrequest.eml"
          ' Create a new CredentialCache object and fill it with the network
          ' credentials required to access the server.
          'Dim policy as System.
          System.Net.ServicePointManager.CertificatePolicy = New AcceptAllCertificatePolicy
          MyCredentialCache = New System.Net.CredentialCache
          'MyCredentialCache.Add(New System.Uri(strMtgUri), _
          '                      "NTLM", _
          '                      New System.Net.NetworkCredential(strUserName, strPassWord, strExchSvrName) _
          '                      )
          MyCredentialCache.Add(New System.Uri(strMtgUri), _
                                "BASIC", _
                                New System.Net.NetworkCredential(strUserName, strPassWord) _
                                )
          strMtgUri = strMtgUri & "/" & "ORS_" & l_sno & "_meeting.eml"
          ' 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:x=""xml:"" xmlns:cal=""urn:schemas:calendar:"" " & _
             "xmlns:dt=""urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"" " & _
             "xmlns:header=""urn:schemas:mailheader:"" " & _
             "xmlns:mail=""urn:schemas:httpmail:"""

          '"<cal:dtstart dt:dt=""dateTime.tz"">" & Fromdt.ToString("yyyy-MM-dd") & "T" & Fromdt.ToString("HH:mm:ss") & ".000Z" & "</cal:dtstart>" & _
          '   "<cal:dtend dt:dt=""dateTime.tz"">" & Todt.ToString("yyyy-MM-dd") & "T" & Todt.ToString("HH:mm:ss") & ".000Z" & "</cal:dtend>" & _
          Dim B_Type As String
          Fms_Obj = New FMS.Database
          B_Type = Fms_Obj.GetString("SELECT F_BH_BOOKTYPE FROM BOOKHD WHERE F_BH_ID = " & l_sno)
          If Not Fms_Obj Is Nothing Then Fms_Obj.Close()
              If Freq_Type = "D" Then
 ' Note: This will executes when the meeting is daily basis
                  Days = Fms_Obj.GetString("SELECT COUNT(DISTINCT(F_BD_DATE)) FROM BOOKDETDATE WHERE F_BD_ID=" & l_sno)
                  strCalInfo = "<cal:location>" & location & "</cal:location>" & _
                  "<cal:dtstart dt:dt=""dateTime.tz"">" & Fromdt.ToString("yyyy-MM-dd") & "T" & Fromdt.ToString("HH:mm:ss") & ".000Z" & "</cal:dtstart>" & _
                  "<cal:dtend dt:dt=""dateTime.tz"">" & Fromdt.ToString("yyyy-MM-dd") & "T" & Todt.ToString("HH:mm:ss") & ".000Z" & "</cal:dtend>" & _
                  "<cal:instancetype dt:dt=""int"">1</cal:instancetype>" & _
                  "<cal:busystatus>BUSY</cal:busystatus>" & _
                  "<cal:meetingstatus>CONFIRMED</cal:meetingstatus>" & _
                  "<cal:alldayevent dt:dt=""boolean"">0</cal:alldayevent>" & _
                  "<cal:timezoneid>cdoHongkong</cal:timezoneid>" & _
                  "<cal:responserequested dt:dt=""boolean"">1</cal:responserequested>" & _
                  "<cal:rrule dt:dt=""mv.string""><x:v>FREQ=DAILY;COUNT=" & Days & "</x:v>" & _
                  "</cal:rrule>"
              Else
    ' Note: This will executes when the meeting is selected day basis
                  Dim Rec_Dates As String
                  Rec_Dates = Find_Days(l_sno)
                  strCalInfo = "<cal:location>" & location & "</cal:location>" & _
                  "<cal:dtstart dt:dt=""dateTime.tz"">" & Fromdt.ToString("yyyy-MM-dd") & "T" & Fromdt.ToString("HH:mm:ss") & ".000Z" & "</cal:dtstart>" & _
                  "<cal:dtend dt:dt=""dateTime.tz"">" & Fromdt.ToString("yyyy-MM-dd") & "T" & Todt.ToString("HH:mm:ss") & ".000Z" & "</cal:dtend>" & _
                  "<cal:instancetype dt:dt=""int"">1</cal:instancetype>" & _
                  "<cal:busystatus>BUSY</cal:busystatus>" & _
                  "<cal:meetingstatus>CONFIRMED</cal:meetingstatus>" & _
                  "<cal:recurtype>2</cal:recurtype>" & _
                  "<cal:alldayevent dt:dt=""boolean"">0</cal:alldayevent>" & _
                  "<cal:timezoneid>cdoHongkong</cal:timezoneid>" & _
                  "<cal:responserequested dt:dt=""boolean"">1</cal:responserequested>" & _
                  " <cal:rdate dt:dt=""mv.dateTime.tz"">" & Rec_Dates & _
                  " </cal:rdate> "
              End If
        
          ' Set the required and optional attendees of the meeting
          ' and the meeting resources.
          strHeaderInfo = "<header:to>" & strReqAttendees & "</header:to>"
          If (strOptAttendees <> "") Then
              strHeaderInfo = strHeaderInfo & "<header:cc>" & strOptAttendees & "</header:cc>"
          End If
          If (strMtgResources = "") Then
              strMtgResources = strMtgResources & "<header:bcc>" & strMtgResources & "</header:bcc>"
          End If

          ' Set the subject of the meeting.
          strMailInfo = "<mail:subject>" & MailSub & "</mail:subject>" & _
             "<mail:htmldescription xml:space=""preserve"">" & L_Body & "</mail:htmldescription>"
          ' Build the XML body of the PROPPATCH request.
          strMtgRequest = "<?xml version=""1.0""?>" & _
          "<g:propertyupdate " & strXMLNSInfo & ">" & _
           "<g:set><g:prop>" & _
             "<g:contentclass>urn:content-classes:appointment</g:contentclass>" & _
             "<e:outlookmessageclass>IPM.Appointment</e:outlookmessageclass>" & _
             strMailInfo & _
             strCalInfo & _
             strHeaderInfo & _
             "<mapi:finvited dt:dt=""boolean"">1</mapi:finvited>" & _
            "</g:prop></g:set>" & _
          "</g:propertyupdate>"
          bResult = False
          ' Create the meeting item in the organizer's calendar folder.
          bResult = CreateMeeting(strMtgUri, strMtgRequest, MyCredentialCache)
          If bResult Then
              ' Get urn:schemas:calendar:uid property, which needs to be included in the meeting request.
              strUID = FindMeetingUID(strMtgUri, MyCredentialCache)
              If strUID <> "" Then
                  ' Set the meeting request item contentclass and outlookmessage class properties.
                  strCCInfo = "<g:contentclass>urn:content-classes:calendarmessage</g:contentclass>" & _
                      "<e:outlookmessageclass>IPM.Schedule.Meeting.Request</e:outlookmessageclass>"
                  ' Set the meeting request item MAPI properties.
                  strMapiInfo = "<mapi:finvited dt:dt=""boolean"">1</mapi:finvited>" & _
                      "<mapi:responsestatus dt:dt=""int"">1</mapi:responsestatus>" & _
                      "<mapi:responsestate dt:dt=""int"">0</mapi:responsestate>" & _
                      "<mapi:response_requested dt:dt=""boolean"">1</mapi:response_requested>" & _
                      "<mapi:apptstateflags dt:dt=""int"">3</mapi:apptstateflags>" & _
                      "<mapi:busystatus dt:dt=""int"">1</mapi:busystatus>" & _
                      "<mapi:intendedbusystatus dt:dt=""int"">2</mapi:intendedbusystatus>"
                  ' Build the XML request body of the meeting request item.
                  strMtgRequest = "<?xml version=""1.0""?>" & _
                      "<g:propertyupdate " & strXMLNSInfo & ">" & _
                          "<g:set>" & _
                          "<g:prop>" & _
                              strCCInfo & _
                              strMailInfo & _
                              strCalInfo & "<cal:uid>" & strUID & "</cal:uid>" & _
                              strHeaderInfo & _
                              strMapiInfo & _
                          "</g:prop>" & _
                          "</g:set>" & _
                      "</g:propertyupdate>"
                  ' Create the meeting request item in the organizer's calendar.
                  bResult = False
                  bResult = CreateMeeting(strMtgRequestUri, strMtgRequest, MyCredentialCache)
                  If bResult Then
                      ' Build the mail submission URI of the meeting organizer.
                      strSubmissionUri = "http://" & strExchSvrName & "/exchange/" & _
                      strMailbox & "/##DavMailSubmissionURI##/"
                      ' MOVE the meeting request item to mail submission URI (send the meeting request).
                      bResult = False
                      bResult = SubmitMeetingRequest(strMtgRequestUri, strSubmissionUri, MyCredentialCache)
                      'For Exchange Log
                    End If
              End If
          End If
        End Sub

Function CreateMeeting(ByVal strMtgUri As String, ByVal strMtgRequest As String, _
                      ByVal MyCredentialCache As System.Net.CredentialCache) As Boolean
          ' Variables.
          Dim PROPPATCHRequest As System.Net.HttpWebRequest
          Dim PROPPATCHResponse As System.Net.WebResponse
          Dim bytes() As Byte
          Dim PROPPATCHRequestStream As System.IO.Stream
          Try
              System.Net.ServicePointManager.CertificatePolicy = New AcceptAllCertificatePolicy
              ' Create the HttpWebRequest object.
              PROPPATCHRequest = CType(System.Net.HttpWebRequest.Create(strMtgUri), _
                                       System.Net.HttpWebRequest)
              ' Add the network credentials to the request.
              PROPPATCHRequest.Credentials = MyCredentialCache
              ' Specify the PROPPATCH method.
              PROPPATCHRequest.Method = "PROPPATCH"
              ' Set the content type header.
              PROPPATCHRequest.ContentType = "text/xml"
              ' Encode the body using UTF-8.
              bytes = System.Text.Encoding.UTF8.GetBytes(strMtgRequest)
              ' Set the content header length.  This must be
              ' done before writing data to the request stream.
              PROPPATCHRequest.ContentLength = bytes.Length
              ' Get a reference to the request stream.
              PROPPATCHRequestStream = PROPPATCHRequest.GetRequestStream()
              ' Write the message body to the request stream.
              PROPPATCHRequestStream.Write(bytes, 0, bytes.Length)
              ' Close the Stream object to release the connection
              ' for further use.
              PROPPATCHRequestStream.Close()
              ' Create the appointment in the Calendar folder of the
              ' user's mailbox.
              PROPPATCHResponse = CType(PROPPATCHRequest.GetResponse(), System.Net.HttpWebResponse)
              ' Clean up.
              PROPPATCHResponse.Close()
              'Console.WriteLine("Meeting successfully created.")
              CreateMeeting = True
          Catch ex As Exception
              ' Catch any exceptions. Any error codes from the PROPPATCH
              ' method request on the server will be caught
              ' here, also.
              CreateMeeting = False
          End Try
      End Function

      Public Function FindMeetingUID(ByVal strMtgUri As String, _
                                   ByVal MyCredentialCache As System.Net.CredentialCache) As String
            '            ' Variables.
          Dim PROPFINDRequest As System.Net.HttpWebRequest
          Dim PROPFINDResponse As System.Net.WebResponse
          Dim bytes() As Byte
          Dim PROPFINDRequestStream As System.IO.Stream
          Dim strUIDRequest As String
          Dim ResponseStream As System.IO.Stream
          Dim ResponseXmlDoc As System.Xml.XmlDocument
          Dim UIDNodes As System.Xml.XmlNodeList
          Dim elem As System.Xml.XmlElement
          Dim colMultiStatusAtts As System.Xml.XmlAttributeCollection
          Dim strCalendarPrefix As String
          Try
              '  Build the PROPFIND request body.
              strUIDRequest = "<?xml version='1.0'?>" & _
                   "<a:propfind xmlns:a='DAV:'>" & _
                   "<a:prop xmlns:uid='urn:schemas:calendar:'>" & _
                   "<uid:uid/></a:prop>" & _
                   "</a:propfind>"
              ' Create the HttpWebRequest object.
              PROPFINDRequest = CType(System.Net.HttpWebRequest.Create(strMtgUri), _
                                      System.Net.HttpWebRequest)
              ' Add the network credentials to the request.
              PROPFINDRequest.Credentials = MyCredentialCache
              ' Specify the PROPPATCH method.
              PROPFINDRequest.Method = "PROPFIND"
              ' Set the content type header.
              PROPFINDRequest.ContentType = "text/xml"
              ' Encode the body using UTF-8.
              bytes = System.Text.Encoding.UTF8.GetBytes(strUIDRequest)
              ' Set the content header length.  This must be
              ' done before writing data to the request stream.
              PROPFINDRequest.ContentLength = bytes.Length
              ' Get a reference to the request stream.
              PROPFINDRequestStream = PROPFINDRequest.GetRequestStream()
              ' Write the message body to the request stream.
              PROPFINDRequestStream.Write(bytes, 0, bytes.Length)
              ' Close the Stream object to release the connection
              ' for further use.
              PROPFINDRequestStream.Close()
              ' Create the meeting in the Calendar folder of the
              ' user's mailbox.
              PROPFINDResponse = CType(PROPFINDRequest.GetResponse(), System.Net.HttpWebResponse)
              ' Get the XML response stream.
              ResponseStream = PROPFINDResponse.GetResponseStream()
              ' Create the XmlDocument object from the XML response stream.
              ResponseXmlDoc = New System.Xml.XmlDocument
              ResponseXmlDoc.Load(ResponseStream)
              ' Get the DAV:multistatus element.
              elem = ResponseXmlDoc.DocumentElement
              ' Get collection of xmlns attributes.
              colMultiStatusAtts = elem.Attributes
              ' Get the prefix for the urn:schemas:calendar: namespace.
              strCalendarPrefix = ""
              For Each att As System.Xml.XmlAttribute In colMultiStatusAtts
                  ' Attribute values are in this format:  xmlns:a="DAV:"
                  If Not att.OuterXml.IndexOf("urn:schemas:calendar:") = -1 Then
                      strCalendarPrefix = att.OuterXml.Substring(6, 1)
                  End If
              Next
              ' Get the urn:schemas:calendar:uid node (there should only be one).
              UIDNodes = ResponseXmlDoc.GetElementsByTagName(strCalendarPrefix & ":uid")
              ' Clean up.
              PROPFINDResponse.Close()
              ResponseStream.Close()
              If UIDNodes.Count = 1 Then
                  Console.WriteLine("Meeting item urn:schemas:calendar:uid found.")
                  FindMeetingUID = UIDNodes(0).InnerText
              Else
                  'Console.WriteLine("Meeting item urn:schemas:calendar:uid not found.")
                  FindMeetingUID = ""
              End If
          Catch ex As Exception
              'Dim Fms_Obj As New FMS.Database
              'Dim Err_Str As String
              'Fms_Obj.Execute("INSERT INTO EXCHANGE_ERROR(ERROR_NO,ERROR_DESC,ERROR_DATE) VALUES (")
              'If Not Fms_Obj Is Nothing Then Fms_Obj.Close()
              ' Catch any exceptions. Any error codes from the PROPFIND
              ' method request on the server will be caught
              ' here, also.
              FindMeetingUID = ""
          End Try
        End Function

      Function SubmitMeetingRequest(ByVal strMtgRequestUri As String, ByVal strSubmissionUri As String, _
                              ByVal MyCredentialCache As System.Net.CredentialCache) As Boolean
            ' Variables.
          Dim MOVERequest As System.Net.HttpWebRequest
          Dim MOVEResponse As System.Net.WebResponse
          Try
              ' Create the HttpWebRequest object.
              MOVERequest = CType(System.Net.HttpWebRequest.Create(strMtgRequestUri), _
                                  System.Net.HttpWebRequest)
              ' Add the network credentials to the request.
              MOVERequest.Credentials = MyCredentialCache
              ' Specify the MOVE method.
              MOVERequest.Method = "MOVE"
              ' Set the Destination header.
              MOVERequest.Headers.Add("Destination", strSubmissionUri)
              ' Set the content type header.
              MOVERequest.ContentType = "message/rfc822"
              ' Submit the meeting request.
              MOVEResponse = CType(MOVERequest.GetResponse(), System.Net.HttpWebResponse)
              ' Clean up.
              MOVEResponse.Close()
              'Console.WriteLine("Meeting request successfully sent.")
              SubmitMeetingRequest = True
          Catch ex As Exception
              ' Catch any exceptions. Any error codes from the MOVE
              ' method request on the server will be caught
              ' here, also.
              SubmitMeetingRequest = False
          End Try
  End Function
   
Function Find_Days(ByVal l_sno As Integer) As String
            Dim Fms_Obj As New FMS.Database
          Dim Fms_Ds As New DataSet
          Dim St_Time As DateTime
          Dim End_Time As DateTime
          Fms_Obj.GetDataSet("SELECT DISTINCT(F_BD_FROMTIME),F_BD_TOTIME FROM BOOKDETDATE WHERE F_BD_ID = " & l_sno, Fms_Ds)
          Dim Cnt As Integer
          For Cnt = 0 To Fms_Ds.Tables(0).Rows.Count - 1
              St_Time = CDate(Fms_Ds.Tables(0).Rows(Cnt).Item(0))
              End_Time = CDate(Fms_Ds.Tables(0).Rows(Cnt).Item(1))
              Find_Days = Find_Days & "<x:v>" & CDate(St_Time).ToString("yyyy-MM-dd") & "T" & CDate(St_Time).ToString("HH:mm:ss") & ".000Z" & "</x:v>"
              Find_Days = Find_Days & "<x:v>" & CDate(End_Time).ToString("yyyy-MM-dd") & "T" & CDate(End_Time).ToString("HH:mm:ss") & ".000Z" & "</x:v>"
          Next
          If Not Fms_Obj Is Nothing Then Fms_Obj.Close()
          Return Find_Days
      End Function


Thanks in Advance.

With Regards,
Nagarajan G




Page: [1]