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

VB.NET Discussion :

problème réception mail


Sujet :

VB.NET

  1. #1
    Invité
    Invité(e)
    Par défaut problème réception mail
    bonjour,

    dans ma messagerie j'ai un léger problème quand je veut recevoir des mail
    cela marche a moitié il reçoit quelque mail puis ensuite arriver a un mail qui doit pas bien lui plaire il me souligne cette ligne de code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    .NomEmetteur = oAscii.DecodeToAscii(strTMP.Substring(0, strTMP.IndexOf("<") - 1).Replace("""", ""))
    et il me dit comme erreur:
    La longueur ne peut pas être inférieure à zéro.
    Nom du paramètre : length
    je vous mets la suite du code si sa peut aider
    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
    Private Sub RecupereEntete(ByVal strChaine As String, ByVal omail As Mail)
                Dim intIndex As Integer
                Dim strTMP As String = ""
     
                oAscii = New Conversion.AsciiIso
     
                With omail
     
                    'on récupère : 
     
                    'l'émetteur  
                    intindex = strChaine.ToLower.IndexOf("from:")
                    If intindex <> -1 Then
                        strTMP = strChaine.Substring(intindex + 6)
                        strTMP = strTMP.Substring(0, strTMP.IndexOf(vbCrLf))
                        If strTMP.IndexOf("<") = -1 Then
                            .NomEmetteur = strTMP.Trim(" "c).Replace("""", "")
                            .AdresseEmetteur = strTMP.Trim(" "c).Replace("""", "")
                        Else
                            .NomEmetteur = oAscii.DecodeToAscii(strTMP.Substring(0, strTMP.IndexOf("<") - 1).Replace("""", ""))
                            .AdresseEmetteur = strTMP.Substring(strTMP.IndexOf("<") + 1, strTMP.IndexOf(">") - strTMP.IndexOf("<") - 1)
                        End If
                    Else 'si on trouve pas 
                        .NomEmetteur = "Inconnu"
                        .AdresseEmetteur = "Inconnu"
                    End If
     
                    'l'objet
                    intindex = strChaine.ToLower.IndexOf("subject:")
                    If intindex <> -1 Then
                        strTMP = strChaine.Substring(intindex + 9)
                        .Objet = oAscii.DecodeToAscii(strTMP.Substring(0, strTMP.IndexOf(vbCrLf)))
                    Else 'si on trouve pas 
                        .Objet = "Aucun"
                    End If
     
                    'Date
                    Try
                        intIndex = strChaine.ToLower.IndexOf("date:")
                        If intIndex <> -1 Then
                            strTMP = strChaine.Substring(intIndex + 6)
                            strTMP = strTMP.Substring(0, strTMP.IndexOf(vbCrLf))
                            strTMP = strTMP.Substring(0, strTMP.LastIndexOf(":") + 2)
                            .DateMail = CType(Format(strTMP, "General Date"), Date)
                        Else
                            .DateMail = Now.Date
                        End If
                    Catch ex As Exception
                        .DateMail = Now.Date
                    End Try
     
     
                    'récepteur
                    intindex = strChaine.ToLower.IndexOf("to:")
                    If intindex <> -1 Then
                        strTMP = strChaine.Substring(intindex + 4)
                        strTMP = strTMP.Substring(0, strTMP.IndexOf(vbCr))
                        If strTMP.IndexOf("<") = -1 Then
                            .NomRecepteur = strTMP.Trim(" "c)
                            .AdresseRecepteur = strTMP.Trim(" "c)
                        Else
                            .NomRecepteur = oAscii.DecodeToAscii(strTMP.Substring(0, strTMP.IndexOf("<")).Replace("""", ""))
                            .AdresseRecepteur = strTMP.Substring(strTMP.IndexOf("<") + 1, strTMP.IndexOf(">") - strTMP.IndexOf("<") - 1)
                        End If
                    Else 'on trouve pas 
                        'normalement il doit y avoir l'émetteur sinon on la recevrait pas 
                    End If
     
                    'Priorité: 
                    intIndex = strChaine.ToLower.IndexOf("x-priority:")
                    If intIndex <> -1 Then
                        .Priorite = Convert.ToInt32(strChaine.Substring(intIndex + 12, 1))
                    Else
                        .Priorite = 3
                    End If
     
                    'Adresse de réponse 
                    intIndex = strChaine.ToLower.IndexOf("reply-to:")
                    If intIndex <> -1 Then
                        strTMP = strChaine.Substring(intIndex + 10)
                        .ReplyTo = strTMP.Substring(0, strTMP.IndexOf(vbCr))
                    Else 'sinon on met l'adresse de l'émetteur
                        .ReplyTo = .AdresseEmetteur
                    End If
     
                    'le message n'est pas encore lu 
                    .Lu = "1"
                End With
     
            End Sub
    Dernière modification par Deepin ; 07/03/2011 à 11h33. Motif: Balises [QUOTE]...[/QUOTE]

  2. #2
    Rédacteur/Modérateur


    Homme Profil pro
    Développeur .NET
    Inscrit en
    Février 2004
    Messages
    19 875
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2004
    Messages : 19 875
    Par défaut
    IndexOf renvoie -1 s'il ne trouve pas la chaine spécifiée, donc ça fait que tu passes -2 comme longueur dans Substring... ce qui n'est évidemment pas une valeur correcte

  3. #3
    Invité
    Invité(e)
    Par défaut
    d'accord vu que le nombre ne peut pas être inférieur a zéro il faut mettre +1 ?

  4. #4
    Rédacteur/Modérateur


    Homme Profil pro
    Développeur .NET
    Inscrit en
    Février 2004
    Messages
    19 875
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2004
    Messages : 19 875
    Par défaut
    Citation Envoyé par Morpheus500 Voir le message
    d'accord vu que le nombre ne peut pas être inférieur a zéro il faut mettre +1 ?
    Non, il faut gérer le cas où strTMP ne contient pas "<". Je ne sais pas à quoi correspond ce caractère dans le contexte de ton application, donc là je peux pas vraiment t'aider...

  5. #5
    Invité
    Invité(e)
    Par défaut
    et bien la, moi non plus je ne sais pas a quoi sa correspond
    j'ai télécharger cette sources sur un autre pour amélioré l'application
    donc je ne sais pas a quoi sa correspond
    Dernière modification par Domi2 ; 19/08/2011 à 14h37.

  6. #6
    Rédacteur/Modérateur


    Homme Profil pro
    Développeur .NET
    Inscrit en
    Février 2004
    Messages
    19 875
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2004
    Messages : 19 875
    Par défaut
    Il me semble quand même pas terrible ce code...
    A ta place j'utiliserais plutôt une librairie toute faite genre OpenPOP, ça a l'air assez simple d'utilisation, il y a même une ébauche de tutoriel ici :
    http://www.developpez.net/forums/d10...t/#post5783817

  7. #7
    Invité
    Invité(e)
    Par défaut
    en faite c'est une moitié de code d'une classe que j'ai mis
    voici le code tout entier de ma classe
    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
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    Namespace Utilitaire
     
        Public Class DecoderMail
     
            'Variables
            Private oMail As Mail
            Private oIndesirable As ContactsIndesirables
            Private oAscii As Conversion.AsciiIso
            Private oES As ES
     
     
    #Region "Constructeur"
     
            Public Sub New(ByVal M As Mail, ByVal C As ContactsIndesirables)
                oMail = M
                oIndesirable = C
            End Sub
     
    #End Region
     
            '''''''''''''''''''''''  Méthodes  ''''''''''''''''''''''''
            'publiques
    #Region "on extrait les élements"
     
            Public Sub ExtractionElements()
                Dim NumMAil As Integer = 0
                Dim strChaine As String = ""
                Dim booTrouver As Boolean
     
                'on va chercher le fichier
                oES = New ES(oMail.AdresseCorpsEntier)
                strChaine = oES.OuvrirFichier()
     
                'on extrait les différentes informations
                RecupereEntete(strChaine, oMail)
     
                recupereCorpsHtml(strChaine, oMail)
     
                recupereCorpsTxt(strChaine, oMail)
     
                RecuperePJ(strChaine, oMail)
     
                'on change la catégorie
                booTrouver = False
                For Each C As ContactIndesirable In oIndesirable
                    If C.AdresseMail = oMail.AdresseEmetteur OrElse C.Nom = oMail.NomEmetteur Then
                        booTrouver = True
                        Exit For
                    End If
     
                Next
                'si on a trouve l'adresse mail ou le nom de l'émetteur dans les indésirables,
                ' on met le mail dans les indésirables 
     
                If booTrouver Then
                    oMail.Categorie = Mail.Categories.Indesirable
                Else
                    oMail.Categorie = Mail.Categories.BoiteReception
                End If
     
     
            End Sub
     
    #End Region
     
     
            'privées
    #Region "Recupere entete"
     
            Private Sub RecupereEntete(ByVal strChaine As String, ByVal omail As Mail)
                Dim intIndex As Integer
                Dim strTMP As String = ""
     
                oAscii = New Conversion.AsciiIso
     
                With omail
     
                    'on récupère : 
     
                    'l'émetteur  
                    intindex = strChaine.ToLower.IndexOf("from:")
                    If intindex <> -1 Then
                        strTMP = strChaine.Substring(intindex + 6)
                        strTMP = strTMP.Substring(0, strTMP.IndexOf(vbCrLf))
                        If strTMP.IndexOf("<") = -1 Then
                            .NomEmetteur = strTMP.Trim(" "c).Replace("""", "")
                            .AdresseEmetteur = strTMP.Trim(" "c).Replace("""", "")
                        Else
                            .NomEmetteur = oAscii.DecodeToAscii(strTMP.Substring(0, strTMP.IndexOf("<") - 1).Replace("""", ""))
                            .AdresseEmetteur = strTMP.Substring(strTMP.IndexOf("<") + 1, strTMP.IndexOf(">") - strTMP.IndexOf("<") - 1)
                        End If
                    Else 'si on trouve pas 
                        .NomEmetteur = "Inconnu"
                        .AdresseEmetteur = "Inconnu"
                    End If
     
                    'l'objet
                    intindex = strChaine.ToLower.IndexOf("subject:")
                    If intindex <> -1 Then
                        strTMP = strChaine.Substring(intindex + 9)
                        .Objet = oAscii.DecodeToAscii(strTMP.Substring(0, strTMP.IndexOf(vbCrLf)))
                    Else 'si on trouve pas 
                        .Objet = "Aucun"
                    End If
     
                    'Date
                    Try
                        intIndex = strChaine.ToLower.IndexOf("date:")
                        If intIndex <> -1 Then
                            strTMP = strChaine.Substring(intIndex + 6)
                            strTMP = strTMP.Substring(0, strTMP.IndexOf(vbCrLf))
                            strTMP = strTMP.Substring(0, strTMP.LastIndexOf(":") + 2)
                            .DateMail = CType(Format(strTMP, "General Date"), Date)
                        Else
                            .DateMail = Now.Date
                        End If
                    Catch ex As Exception
                        .DateMail = Now.Date
                    End Try
     
     
                    'récepteur
                    intindex = strChaine.ToLower.IndexOf("to:")
                    If intindex <> -1 Then
                        strTMP = strChaine.Substring(intindex + 4)
                        strTMP = strTMP.Substring(0, strTMP.IndexOf(vbCr))
                        If strTMP.IndexOf("<") = -1 Then
                            .NomRecepteur = strTMP.Trim(" "c)
                            .AdresseRecepteur = strTMP.Trim(" "c)
                        Else
                            .NomRecepteur = oAscii.DecodeToAscii(strTMP.Substring(0, strTMP.IndexOf("<")).Replace("""", ""))
                            .AdresseRecepteur = strTMP.Substring(strTMP.IndexOf("<") + 1, strTMP.IndexOf(">") - strTMP.IndexOf("<") - 1)
                        End If
                    Else 'on trouve pas 
                        'normalement il doit y avoir l'émetteur sinon on la recevrait pas 
                    End If
     
                    'Priorité: 
                    intIndex = strChaine.ToLower.IndexOf("x-priority:")
                    If intIndex <> -1 Then
                        .Priorite = Convert.ToInt32(strChaine.Substring(intIndex + 12, 1))
                    Else
                        .Priorite = 3
                    End If
     
                    'Adresse de réponse 
                    intIndex = strChaine.ToLower.IndexOf("reply-to:")
                    If intIndex <> -1 Then
                        strTMP = strChaine.Substring(intIndex + 10)
                        .ReplyTo = strTMP.Substring(0, strTMP.IndexOf(vbCr))
                    Else 'sinon on met l'adresse de l'émetteur
                        .ReplyTo = .AdresseEmetteur
                    End If
     
                    'le message n'est pas encore lu 
                    .Lu = "1"
                End With
     
            End Sub
     
    #End Region
     
    #Region "recupere corps HTML"
     
            Private Sub recupereCorpsHtml(ByVal strChaine As String, ByRef omail As Mail)
                Dim intIndex As Integer = 0
                oAscii = New Conversion.AsciiIso
     
                'on récupère la partie du mail qui est au format html
                'avant de commencer, on enlève les = à la fin des lignes, cela peut empêcher 
                'la détection du <html>
                'strChaine = strChaine.Replace("=" & ChrW(13) & ChrW(10), "")
                intIndex = strChaine.ToLower.IndexOf("content-type: text/html")
     
                If intIndex <> -1 Then
                    'on commence juste avant le <html> après le boudary
                    strChaine = strChaine.Substring(intIndex + 24)
                    intIndex = strChaine.ToLower.IndexOf("<html>")
                    If intIndex <> -1 Then
                        strChaine = strChaine.Substring(intIndex)
                    Else
                        'si on ne trouve pas le html on commence après le premier double saut à la ligne
                        strChaine = strChaine.Substring(strChaine.IndexOf(vbCrLf & vbCrLf))
                    End If
     
                    ' Maintenant il faut trouver où la partie s'arrête  : 
                    ' soit avant un autre boudary soit à la fin du mail (.) , soit après la balise </html>
                    If strChaine.ToLower.IndexOf("</html>") <> -1 Then
                        'si on trouve la balise </html> c'est le must 
                        intIndex = strChaine.ToLower.IndexOf("</html>")
                        strChaine = strChaine.Substring(0, intIndex + 7)
                    ElseIf strChaine.ToLower.IndexOf("boundary") <> -1 Then
                        'si on trouve une autre balise boudary on s'arrête au saut à ligne juste avant.
                        intIndex = strChaine.ToLower.IndexOf("boundary")
                        strChaine = strChaine.Substring(0, intIndex)
                        strChaine = strChaine.Substring(0, strChaine.LastIndexOf(vbCr))
                    ElseIf strChaine.ToLower.LastIndexOf(".") <> -1 Then
                        'sinon on s'arrête avant le . final 
                        strChaine = strChaine.Substring(0, strChaine.LastIndexOf("."))
                    Else 'sinon il y a une erreur
                        strChaine = "- Erreur -"
                    End If
     
                Else
                    strChaine = "- pas de format html -"
                End If
     
                'on convertit si c'est de l'iso, du windows ou des caras speciaux
                strChaine = oAscii.DecodeToAscii(strChaine)
     
                'on enregistre dans un fichier 
                oES = New Utilitaire.ES(omail.Identifiant & "\CorpHtml.htm", ES.Dossier.Body)
     
                With oES
                    .Enregistrer(strChaine)
                End With
                omail.AdresseCorpsHtml = oES.CheminFichier
     
                oES = Nothing
                oAscii = Nothing
     
            End Sub
     
    #End Region
     
    #Region "recupere corps txt"
     
            Private Sub recupereCorpsTxt(ByVal strChaine As String, ByVal oMail As Mail)
                Dim intIndex As Integer = 0
                oAscii = New Conversion.AsciiIso
                On Error Resume Next
     
                'on recupere la partie du mail qui est au format text
                intIndex = strChaine.ToLower.IndexOf("content-type: text/plain")
                If intIndex <> -1 Then
                    'ici on a trouvé la balise
                    strChaine = strChaine.Substring(intIndex + 24)
                    'la partie text commence juste apres les 2 prochain saut à la ligne
                    strChaine = strChaine.Substring(strChaine.IndexOf(vbCrLf & vbCrLf))
                    'maintenant il faut trouver la fin de la partie text 
                    If strChaine.ToLower.IndexOf("boundary") <> -1 Then
                        'si on trouve une autre artie apres, on 'arrete juste avant 
                        intIndex = strChaine.ToLower.IndexOf("boundary")
                        strChaine = strChaine.Substring(0, intIndex)
                        strChaine = strChaine.Substring(0, strChaine.LastIndexOf(vbCrLf & vbCrLf))
                    ElseIf strChaine.ToLower.IndexOf("content-type: text/html") <> -1 Then
                        'on regarde si on trouve une partie HTML apres
                        intIndex = strChaine.ToLower.IndexOf("content-type: text/html")
                        strChaine = strChaine.Substring(0, intIndex)
                        strChaine = strChaine.Substring(0, strChaine.LastIndexOf(vbCrLf & vbCrLf))
                    ElseIf strChaine.LastIndexOf(".") <> -1 Then
                        's'il n'y a pas d'autre partie, on s'arrete juste avant le point final
                        strChaine = strChaine.Substring(0, strChaine.LastIndexOf("."))
                    Else 'il y a une erreur
                        strChaine = "- Erreur - "
                    End If
     
                Else
                    'si on n'a pas trouvé la partie text on a 2 solutions : soit il n'y a pas de partie text, 
                    'soit il n'y a qu'une partie text et elle n'est pas decrite. 
                    If strChaine.ToLower.IndexOf("content-type: text/html") <> -1 Then
                        strChaine = "- Pas de partie text - "
                    Else
                        strChaine = strChaine.Substring(Convert.ToInt32(oMail.NombreCaraEntete))
     
                        If strChaine.ToLower.IndexOf("boundary") <> -1 Then
                            'si on trouve une autre partie apres, on s'arrete juste avant (une piece jointe part exemple)  
                            intIndex = strChaine.ToLower.IndexOf("boundary")
                            strChaine = strChaine.Substring(0, intIndex)
                            strChaine = strChaine.Substring(0, strChaine.LastIndexOf(vbCrLf & vbCrLf))
                        ElseIf strChaine.LastIndexOf(".") <> -1 Then
                            's'il n'y a pas d'autre partie, on s'arrete juste avant le point final
                            strChaine = strChaine.Substring(0, strChaine.LastIndexOf("."))
                        Else 'il y a une erreur
                            strChaine = "- Erreur - "
                        End If
                    End If
                End If
     
                'on convertit si c'est de l'iso, du windows ou des caras speciaux
                'on rajoute des balise pour les entrées car le text va être lu par un navigateur
                strChaine = oAscii.DecodeToAscii(strChaine, True)
     
                'on ajoutes des liens là ou il y a écrit http://
                strChaine = oAscii.AjoutLiens(strChaine)
     
                'on enregistre dans un fichier 
                oES = New Utilitaire.ES(oMail.Identifiant & "\Corptext.txt", ES.Dossier.Body)
                With oES
                    .Enregistrer(strChaine)
                End With
     
                oMail.AdresseCorpsText = oES.CheminFichier
     
                oES = Nothing
                oAscii = Nothing
            End Sub
     
    #End Region
     
    #Region "Recupere Les pieces jointes"
     
            Private Sub RecuperePJ(ByRef strText As String, ByVal omail As Mail)
                Dim strTmp As String = strText
                Dim strTmp2 As String = ""
                Dim intIndex As Integer = 0
                Dim o64 As New Conversion.Base64
                Dim oPJS As New PJs
                Dim oPJ As PJ
     
                ' on recherche des parties qui contiennent les piéces jointes 
                ' c'est à dire les parties boudary ou le content-Type et différent 
                ' de Content-Type: Multipart/Alternative, ...
     
                intIndex = strText.ToLower.IndexOf("content-type:")
                While intIndex <> -1
                    strTmp = strText.Substring(intIndex)
                    'si c'est une PJ
                    If RecherchePj(strTmp.Substring(0, strTmp.IndexOf(vbCr))) Then
     
                        'on isole la partie 
                        strTmp = strTmp.Substring(0, strTmp.ToLower.IndexOf("boundary"))
                        strTmp = strTmp.Substring(0, strTmp.LastIndexOf(vbCrLf))
     
                        'on recupere les informations
                        oPJ = New PJ
                        With oPJ
     
                            'on recupere le format
                            intIndex = strTmp.ToLower.IndexOf("content-type")
                            If intIndex <> -1 Then
                                strTmp2 = strTmp.Substring(intIndex + 12)
                                strTmp2 = strTmp2.Substring(0, strTmp2.IndexOf(vbCrLf))
                                .Format = recupereInfo(strTmp2)
                            Else
                                .Format = "- Inconnu -"
                            End If
     
                            intIndex = strTmp.ToLower.IndexOf("name")
                            If intIndex <> -1 Then
                                strTmp2 = strTmp.Substring(intIndex + 12)
                                strTmp2 = strTmp2.Substring(0, strTmp2.IndexOf(vbCrLf))
                                .NomFichier = recupereInfo(strTmp2)
                            Else
                                .NomFichier = "- Inconnu -"
                            End If
                            intIndex = strTmp.ToLower.IndexOf("content-id")
                            If intIndex <> -1 Then
                                strTmp2 = strTmp.Substring(intIndex + 12)
                                strTmp2 = strTmp2.Substring(0, strTmp2.IndexOf(vbCrLf))
                                .Identifiant = recupereInfo(strTmp2)
                            Else
                                .Identifiant = "- Inconnu -"
                            End If
     
                            'strTmp = strTmp.Substring(strTmp.IndexOf(vbCrLf & vbCrLf))
                            'strTmp = strTmp.Substring(0, strTmp.IndexOf("=") + 1)
                            'strTmp = strTmp.Replace(" ", "").Replace(vbCrLf, "")
                            'strTmp = o64.base64ToByte(strTmp)
                            'oES = New ES(.NomFichier, ES.Dossier.Body)
                            'oES.Enregistrer(strTmp)
                        End With
                    Else
     
     
                    End If
                    strText = strText.Substring(intIndex + 13)
                    intIndex = strText.ToLower.IndexOf("content-type:")
                End While
     
     
            End Sub
     
    #End Region
     
    #Region "RecherchePj"
     
            Private Function RecherchePj(ByVal T As String) As Boolean
                T = T.Substring(0, T.IndexOf(";"))
                T = T.Trim(" "c)
     
                If T.ToLower <> "content-type: multipart/alternative" AndAlso T.ToLower <> "content-type: text/plain" AndAlso T.ToLower <> "content-type: text/html" _
                AndAlso T.ToLower <> "content-type: multipart/mixed" AndAlso T.ToLower <> "content-type: multipart/related" Then
                    Return True
                Else
                    Return False
                End If
     
            End Function
     
    #End Region
     
    #Region "REcupereInfo"
     
            Private Function recupereInfo(ByVal T As String) As String
                T = T.Replace(":", "").Replace(";", "").Replace("""", "").Replace("=", "").Replace("<", "").Replace(">", "").Trim(" "c)
                Return T
            End Function
     
    #End Region
     
     
        End Class
     
    End Namespace

Discussions similaires

  1. Problème réception mails
    Par Pov type dans le forum Outlook
    Réponses: 0
    Dernier message: 11/05/2015, 12h39
  2. [Exchange 2010] Problème réception mail depuis un copieur
    Par Vera777 dans le forum Exchange Server
    Réponses: 10
    Dernier message: 14/05/2013, 18h17
  3. Problème Réception Mail mauvais dossier
    Par Arnaud62 dans le forum Administration système
    Réponses: 1
    Dernier message: 01/02/2012, 15h33
  4. [Mail] Problème réception mail/pieces jointes
    Par pymouse dans le forum Langage
    Réponses: 1
    Dernier message: 18/04/2006, 17h07
  5. [Logiciel] Outlook : problème réception massive de mails
    Par malbaladejo dans le forum Outlook
    Réponses: 1
    Dernier message: 09/12/2005, 14h00

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