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

Mode arborescent

Message précédent Message précédent   Message suivant Message suivant
  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]

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