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 |
Partager