IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBA Outlook Discussion :

probléme de création de rdv sous exchange


Sujet :

VBA Outlook

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Février 2008
    Messages
    133
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Février 2008
    Messages : 133
    Points : 71
    Points
    71
    Par défaut probléme de création de rdv sous exchange
    Bonjours tout le monde j'ai un petit souci avec un script qui devrais normalement crée un nouveau rdv dans mon server exchange via une méthode webdav "Propatch", la méthode fonctionnne car je l'ai déja utilisé pour crée un contacte, mais pour les rdv il me renvoie une erreur 400 (demande incorecte), je pense que le problème vien des multistatus que je récupère dans mon xml.
    Voici mon code...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
     
      Dim strExchSvrName As String
            Dim strMailbox As String
            Dim strCalendarUri As String
            Dim strApptItem As String
            Dim strDomain As String
            Dim strUserName As String
            Dim strPassword As String
            Dim strApptRequest As String
            Dim strMailInfo As String
            Dim strCalInfo As String
            Dim strXMLNSInfo As String
            Dim strHeaderInfo As String
            Dim PROPPATCHRequest As System.Net.HttpWebRequest
            Dim PROPPATCHResponse As System.Net.WebResponse
            Dim MyCredentialCache As System.Net.CredentialCache
            Dim bytes() As Byte
            Dim PROPPATCHRequestStream As System.IO.Stream
     
            Try
                ' Exchange server name
                strExchSvrName = "********"
     
                ' Mailbox folder name.
                strMailbox = "*******"
     
                ' Appointment item.
                strApptItem = "*******.eml"
     
                ' URI of the user's calendar folder.
                strCalendarUri = "http://" & strExchSvrName & "/exchange/" & _
                strMailbox & "/Calendar/"
     
                ' User name and password of appointment creator.
                strUserName = "*********"
                strDomain = "************"
                strPassword = "**************"
     
                ' XML namespace info for the WebDAV request.
                'strXMLNSInfo = "xmlns:g->a=""DAV:"" " & _
                '   "xmlns:e->f=""http://schemas.microsoft.com/exchange/"" " & _
                '   "xmlns:mapi=""http://schemas.microsoft.com/mapi/"" " & _
                '   "xmlns:mapit=""http://schemas.microsoft.com/mapi/proptag/"" " & _
                '   "xmlns:x->c=""xml:"" " & _
                '   "xmlns:cal->d=""urn:schemas:calendar:"" " & _
                '   "xmlns:dt->b=""urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"" " & _
                '   "xmlns:header->j=""urn:schemas:mailheader:"" " & _
                '   "xmlns:mail->e=""urn:schemas:httpmail:"""
     
                strXMLNSInfo = "xmlns:a=""DAV:"" " & _
                   "xmlns:f=""http://schemas.microsoft.com/exchange/"" " & _
                   "xmlns:d=""urn:schemas:calendar:"" " & _
                   "xmlns:b=""urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"" " & _
                   "xmlns:j=""urn:schemas:mailheader:"" " & _
                   "xmlns:e=""urn:schemas:httpmail:"""
     
                ' Set the appointment item properties.  The reminder time is set in seconds.
                ' To create an all-day meeting, set the dtstart/dtend range for 24 hours()
                ' or more and set the alldayevent property to 1.  See the documentation()
                ' on the properties in the urn:schemas:calendar: namespace for more information.
                strCalInfo = "<d:location>Dixon</d:location>" & _
                    "<d:dtstart>2006-05-25T04:00:00.000Z</d:dtstart>" & _
                    "<d:dtend >2006-05-28T04:00:00.000Z</d:dtend>" & _
                    "<d:meetingstatus>TENTATIVE</d:meetingstatus>" & _
                    "<d:instancetype>0</d:instancetype>" & _
                    "<d:busystatus>FREE</d:busystatus>" & _
                    "<d:alldayevent>1</d:alldayevent>" & _
                    "<d:responserequested>0</d:responserequested>"
     
                ' Set the required attendee of the appointment.
                strHeaderInfo = "<j:subject>test</j:subject>"
     
     
                ' Set the subject of the appointment.
                strMailInfo = "<e:subject>Webdav Appointment</e:subject>" & _
                "<e:normalizedsubject>test</e:normalizedsubject>" & _
                "<e:hasattachment>0</e:hasattachment>" & _
                "<e:textdescription>bla bla bla</e:textdescription>" & _
                "<e:htmldescription>Test Appointment Body</e:htmldescription>"
     
                ' Build the XML body of the PROPPATCH request.
                strApptRequest = "<?xml version=""1.0""?>" & _
                 "<a:propertyupdate " & strXMLNSInfo & ">" & _
                    "<a:set>" & _
                        "<g:prop>" & _
                            "<a:contentclass>urn:content-classes:appointment</a:contentclass>" & _
                                "<f:outlookmessageclass>IPM.Appointment</f:outlookmessageclass>" & _
                                    strMailInfo & _
                                    strCalInfo & _
                                    strHeaderInfo & _
                        "</a:prop>" & _
                    "</a:set>" & _
                "</a:propertyupdate>"
     
                ' Create a new CredentialCache object and fill it with the network
                ' credentials required to access the server.
                MyCredentialCache = New System.Net.CredentialCache
                MyCredentialCache.Add(New System.Uri(strCalendarUri), _
                                      "NTLM", New System.Net.NetworkCredential(strUserName, strPassword, strDomain))
     
                ' Create the HttpWebRequest object.
                PROPPATCHRequest = CType(System.Net.HttpWebRequest.Create(strCalendarUri & strApptItem), 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(strApptRequest)
     
                ' 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)
     
                Console.WriteLine("Appointment successfully created.")
     
                ' Clean up.
                PROPPATCHResponse.Close()
     
            Catch ex As Exception
                ' Catch any exceptions. Any error codes from the PROPPATCH
                ' or MOVE method requests on the server will be caught
                ' here, also.
                Console.WriteLine(ex.Message)
                MsgBox(ex.Message)
            End Try
     
     
        End Sub
    Merci d'avance

  2. #2
    Membre régulier
    Profil pro
    Inscrit en
    Février 2008
    Messages
    133
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Février 2008
    Messages : 133
    Points : 71
    Points
    71
    Par défaut
    Citation Envoyé par djorfe Voir le message
    Bonjours tout le monde j'ai un petit souci avec un script qui devrais normalement crée un nouveau rdv dans mon server exchange via une méthode webdav "Propatch", la méthode fonctionnne car je l'ai déja utilisé pour crée un contacte, mais pour les rdv il me renvoie une erreur 400 (demande incorecte), je pense que le problème vien des multistatus que je récupère dans mon xml.
    Voici mon code...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
     
      Dim strExchSvrName As String
            Dim strMailbox As String
            Dim strCalendarUri As String
            Dim strApptItem As String
            Dim strDomain As String
            Dim strUserName As String
            Dim strPassword As String
            Dim strApptRequest As String
            Dim strMailInfo As String
            Dim strCalInfo As String
            Dim strXMLNSInfo As String
            Dim strHeaderInfo As String
            Dim PROPPATCHRequest As System.Net.HttpWebRequest
            Dim PROPPATCHResponse As System.Net.WebResponse
            Dim MyCredentialCache As System.Net.CredentialCache
            Dim bytes() As Byte
            Dim PROPPATCHRequestStream As System.IO.Stream
     
            Try
                ' Exchange server name
                strExchSvrName = "********"
     
                ' Mailbox folder name.
                strMailbox = "*******"
     
                ' Appointment item.
                strApptItem = "*******.eml"
     
                ' URI of the user's calendar folder.
                strCalendarUri = "http://" & strExchSvrName & "/exchange/" & _
                strMailbox & "/Calendar/"
     
                ' User name and password of appointment creator.
                strUserName = "*********"
                strDomain = "************"
                strPassword = "**************"
     
                ' XML namespace info for the WebDAV request.
                'strXMLNSInfo = "xmlns:g->a=""DAV:"" " & _
                '   "xmlns:e->f=""http://schemas.microsoft.com/exchange/"" " & _
                '   "xmlns:mapi=""http://schemas.microsoft.com/mapi/"" " & _
                '   "xmlns:mapit=""http://schemas.microsoft.com/mapi/proptag/"" " & _
                '   "xmlns:x->c=""xml:"" " & _
                '   "xmlns:cal->d=""urn:schemas:calendar:"" " & _
                '   "xmlns:dt->b=""urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"" " & _
                '   "xmlns:header->j=""urn:schemas:mailheader:"" " & _
                '   "xmlns:mail->e=""urn:schemas:httpmail:"""
     
                strXMLNSInfo = "xmlns:a=""DAV:"" " & _
                   "xmlns:f=""http://schemas.microsoft.com/exchange/"" " & _
                   "xmlns:d=""urn:schemas:calendar:"" " & _
                   "xmlns:b=""urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"" " & _
                   "xmlns:j=""urn:schemas:mailheader:"" " & _
                   "xmlns:e=""urn:schemas:httpmail:"""
     
                ' Set the appointment item properties.  The reminder time is set in seconds.
                ' To create an all-day meeting, set the dtstart/dtend range for 24 hours()
                ' or more and set the alldayevent property to 1.  See the documentation()
                ' on the properties in the urn:schemas:calendar: namespace for more information.
                strCalInfo = "<d:location>Dixon</d:location>" & _
                    "<d:dtstart>2006-05-25T04:00:00.000Z</d:dtstart>" & _
                    "<d:dtend >2006-05-28T04:00:00.000Z</d:dtend>" & _
                    "<d:meetingstatus>TENTATIVE</d:meetingstatus>" & _
                    "<d:instancetype>0</d:instancetype>" & _
                    "<d:busystatus>FREE</d:busystatus>" & _
                    "<d:alldayevent>1</d:alldayevent>" & _
                    "<d:responserequested>0</d:responserequested>"
     
                ' Set the required attendee of the appointment.
                strHeaderInfo = "<j:subject>test</j:subject>"
     
     
                ' Set the subject of the appointment.
                strMailInfo = "<e:subject>Webdav Appointment</e:subject>" & _
                "<e:normalizedsubject>test</e:normalizedsubject>" & _
                "<e:hasattachment>0</e:hasattachment>" & _
                "<e:textdescription>bla bla bla</e:textdescription>" & _
                "<e:htmldescription>Test Appointment Body</e:htmldescription>"
     
                ' Build the XML body of the PROPPATCH request.
                strApptRequest = "<?xml version=""1.0""?>" & _
                 "<a:propertyupdate " & strXMLNSInfo & ">" & _
                    "<a:set>" & _
                        "<a:prop>" & _
                            "<a:contentclass>urn:content-classes:appointment</a:contentclass>" & _
                                "<f:outlookmessageclass>IPM.Appointment</f:outlookmessageclass>" & _
                                    strMailInfo & _
                                    strCalInfo & _
                                    strHeaderInfo & _
                        "</a:prop>" & _
                    "</a:set>" & _
                "</a:propertyupdate>"
     
                ' Create a new CredentialCache object and fill it with the network
                ' credentials required to access the server.
                MyCredentialCache = New System.Net.CredentialCache
                MyCredentialCache.Add(New System.Uri(strCalendarUri), _
                                      "NTLM", New System.Net.NetworkCredential(strUserName, strPassword, strDomain))
     
                ' Create the HttpWebRequest object.
                PROPPATCHRequest = CType(System.Net.HttpWebRequest.Create(strCalendarUri & strApptItem), 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(strApptRequest)
     
                ' 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)
     
                Console.WriteLine("Appointment successfully created.")
     
                ' Clean up.
                PROPPATCHResponse.Close()
     
            Catch ex As Exception
                ' Catch any exceptions. Any error codes from the PROPPATCH
                ' or MOVE method requests on the server will be caught
                ' here, also.
                Console.WriteLine(ex.Message)
                MsgBox(ex.Message)
            End Try
     
     
        End Sub
    Merci d'avance

  3. #3
    Membre habitué
    Inscrit en
    Août 2007
    Messages
    139
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 139
    Points : 178
    Points
    178
    Par défaut
    Bonjour,

    Je comprends pas pour quoi tu utilises cette méthode qui me paraît un peu compliqué.

    A bientôt

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problème de création de pdf sous IE
    Par grognon83 dans le forum IE
    Réponses: 1
    Dernier message: 23/04/2009, 13h42
  2. Problème de création de procédure sous PHPMyAdmin
    Par Braer dans le forum SQL Procédural
    Réponses: 1
    Dernier message: 09/11/2007, 16h05
  3. [SQL-Server] Problème query création de tables sous PHP
    Par DjSoulz dans le forum PHP & Base de données
    Réponses: 3
    Dernier message: 27/03/2007, 22h18
  4. problème de création de requète sous VBA
    Par Golork dans le forum Access
    Réponses: 4
    Dernier message: 02/06/2006, 14h35
  5. Problème de création de table sous MySql
    Par ducamba dans le forum Requêtes
    Réponses: 2
    Dernier message: 21/06/2003, 09h59

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo