cs_pledoux
Messages postés147Date d'inscriptionmardi 12 octobre 2004StatutMembreDernière intervention 6 mars 2007
-
7 janv. 2005 à 14:44
cs_pledoux
Messages postés147Date d'inscriptionmardi 12 octobre 2004StatutMembreDernière intervention 6 mars 2007
-
11 janv. 2005 à 16:08
Bonjour,
J'utilise le code suivant pour expédier des mails en attaquant directement un serveur SMTP. Mais je connais pas les lignes de commande pour :
- mettre des destinataires en copie ou copie cachée,
- joindre un fichier au message (pièce jointe).
cs_pledoux
Messages postés147Date d'inscriptionmardi 12 octobre 2004StatutMembreDernière intervention 6 mars 2007 11 janv. 2005 à 16:08
Pour mettre en copie remplacer "to:" par "cc:" dans la section DATA
Pour mettre en copie cachée remplacer "to:" par "bcc:" dans la section DATA
Pour la pièce jointe voici la fonction UUEncodeFile. Il faut alors mettre la chaine renvoyée avant le "." & vbCrLf. Le fichier "strFilePath" sera alors joint à la fin du message.
Private Function UUEncodeFile(strFilePath As String) As String
Dim intFile As Integer 'file handler
Dim intTempFile As Integer 'temp file
Dim lFileSize As Long 'size of the file
Dim strFilename As String 'name of the file
Dim strFileData As String 'file data chunk
Dim lEncodedLines As Long 'number of encoded lines
Dim strTempLine As String 'temporary string
Dim i As Long 'loop counter
Dim j As Integer 'loop counter
'Prepare buffer to retrieve data from
'the file by 45 symbols chunks
strFileData = Space(45)
intFile = FreeFile
Open strFilePath For Binary As intFile
For i = 1 To lEncodedLines
'Read file data by 45-bytes cnunks
If i = lEncodedLines Then
'Last line of encoded data often is not
'equal to 45, therefore we need to change
'size of the buffer
strFileData = Space(lFileSize Mod 45)
End If
'Retrieve data chunk from file to the buffer
Get intFile, , strFileData
'Add first symbol to encoded string that informs
'about quantity of symbols in encoded string.
'More often "M" symbol is used.
strTempLine = Chr(Len(strFileData) + 32)
If i = lEncodedLines And (Len(strFileData) Mod 3) Then
'If the last line is processed and length of
'source data is not a number divisible by 3, add one or two
'blankspace symbols
strFileData = strFileData + Space(3 - (Len(strFileData) Mod 3))
End If
For j = 1 To Len(strFileData) Step 3
'Breake each 3 (8-bits) bytes to 4 (6-bits) bytes
'1 byte
strTempLine = strTempLine + Chr(Asc(Mid(strFileData, j, 1)) \ 4 + 32)
'2 byte
strTempLine = strTempLine + Chr((Asc(Mid(strFileData, j, 1)) Mod 4) * 16 + Asc(Mid(strFileData, j + 1, 1)) \ 16 + 32)
'3 byte
strTempLine = strTempLine + Chr((Asc(Mid(strFileData, j + 1, 1)) Mod 16) * 4 + Asc(Mid(strFileData, j + 2, 1)) \ 64 + 32)
'4 byte
strTempLine = strTempLine + Chr(Asc(Mid(strFileData, j + 2, 1)) Mod 64 + 32)
Next j
'replace " " with "`"
strTempLine = Replace(strTempLine, " ", "`")
'add encoded line to result buffer
strResult = strResult + strTempLine + vbCrLf
'reset line buffer
strTempLine = ""
Next i
Close intFile
'add the end marker
strResult = strResult & "`" & vbCrLf + "end" + vbCrLf
'asign return value
UUEncodeFile = strResult