Winsock-Ergänzung mit BCC

08/07/2008 - 12:29 von Michael Alexander | Report spam
Hallo!

Ich verwende aus der rkse-SMTP.mdb den Code für den Versand von Mails über
SMTP (die Lösung ist abgewandelt aus dem VB-Projekt "Sendmail" von Ian
Williams) und möchte aber - zur Kontrolle, bzw. zur Dokumentaion in meinem
Browser-Programm eine Kopie des Mails haben. Ich versuche daher, mir selbst
als BCC ein Mail zu senden, nur funktioniert das nicht.

Wo müßte ich diese Adresse einbauen, bzw. wie funktioniert das?

Folgender Code:

Option Compare Database
Option Explicit

' abgewandelt aus dem VB-Projekt "Sendmail" von Ian Williams
' http://www.vbip.com/winsock/winsock...der_02.asp

Private Const MAIL_CONNECT = 0
Private Const MAIL_HELO = 1
Private Const MAIL_FROM = 2
Private Const MAIL_RCPTTO = 3
Private Const MAIL_DATA = 4
Private Const MAIL_DOT = 5
Private Const MAIL_QUIT = 6

'Private Enum SMTP_State
' MAIL_CONNECT
' MAIL_HELO
' MAIL_FROM
' MAIL_RCPTTO
' MAIL_DATA
' MAIL_DOT
' MAIL_QUIT
'End Enum

Private m_State As Long 'SMTP_State
Private m_strEncodedFiles As String
______________________________________

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strServerResponse As String
Dim strResponseCode As String
Dim strDataToSend As String

Dim rs As Recordset

On Error GoTo HandleErr

DoCmd.Hourglass True
'
'Retrive data from winsock buffer
'
Winsock1.GetData strServerResponse
'
'Debug.Print strServerResponse
'
'Get server response code (first three symbols)
'
strResponseCode = Left(strServerResponse, 3)
'
'Only these three codes tell us that previous
'command accepted successfully and we can go on
'
If strResponseCode = "250" Or _
strResponseCode = "220" Or _
strResponseCode = "354" Then

Select Case m_State
Case MAIL_CONNECT
'Change current state of the session
m_State = MAIL_HELO
'
'Remove blank spaces
strDataToSend = Trim$(Nz(Me!txtSender, ""))
'
'Retrieve mailbox name from e-mail address
If strDataToSend <> "" Then _
strDataToSend = Left$(strDataToSend, InStr(1, strDataToSend,
"@") - 1)
'Send HELO command to the server
Winsock1.SendData "HELO " & strDataToSend & vbCrLf
'
'Debug.Print "HELO " & strDataToSend
'
Case MAIL_HELO
'
'Change current state of the session
m_State = MAIL_FROM
'
'Send MAIL FROM command to the server
Winsock1.SendData "MAIL FROM:" & Trim$(Me!txtSender) & vbCrLf
'
'Debug.Print "MAIL FROM:" & Trim$(Me!txtSender)
'
Case MAIL_FROM
'
'Change current state of the session
m_State = MAIL_RCPTTO
'
'Send RCPT TO command to the server
Winsock1.SendData "RCPT TO:" & Trim$(Me!txtRecipient) & vbCrLf
'
'Debug.Print "RCPT TO:" & Trim$(Me!txtRecipient)
'
Case MAIL_RCPTTO
'
'Change current state of the session
m_State = MAIL_DATA
'
'Send DATA command to the server
Winsock1.SendData "DATA" & vbCrLf
'
'Debug.Print "DATA"
'
Case MAIL_DATA
'
'Change current state of the session
m_State = MAIL_DOT
'
'Send Subject line
Winsock1.SendData "From:" & Me!txtSenderName & " <" &
Me!txtSender & ">" & vbCrLf
Winsock1.SendData "To:" & Me!txtRecipientName & " <" &
Me!txtRecipient & ">" & vbCrLf
'test
Winsock1.SendData "To: mir_selbst@eineBCC.cc" & vbCrLf
'
'Debug.Print "Subject: " & Me!txtSubject
'
If Len(Nz(Me!txtReplyTo, "")) > 0 Then
Winsock1.SendData "Subject:" & Me!txtSubject & vbCrLf
Winsock1.SendData "Reply-To:" & Me!txtReplyToName & " <" &
Me!txtReplyTo & ">" & vbCrLf & vbCrLf
Else
Winsock1.SendData "Subject:" & Me!txtSubject & vbCrLf &
vbCrLf
End If
'Hier wird die Message aus Me.txtMessage übernommen!
Dim strMessage As String
'
'Add atacchments
strMessage = Me!txtMessage & vbCrLf & vbCrLf &
m_strEncodedFiles
'Debug.Print Me!txtMessage
'clear memory
m_strEncodedFiles = ""

Winsock1.SendData strMessage & vbCrLf
strMessage = ""
'
'Send a dot symbol to inform server
'that sending of message comleted
Winsock1.SendData "." & vbCrLf
'
'Debug.Print "."
'
Case MAIL_DOT
'Change current state of the session
m_State = MAIL_QUIT
'
'Send QUIT command to the server
Winsock1.SendData "QUIT" & vbCrLf
'
'Debug.Print "QUIT"
Case MAIL_QUIT
'
'Close connection
Winsock1.Close
'
End Select

Else
'
'If we are here server replied with
'unacceptable respose code therefore we need
'close connection and inform user about problem
'
Winsock1.Close
'
If Not m_State = MAIL_QUIT Then
MsgBox "SMTP Fehler: " & strServerResponse, _
vbInformation, "SMTP Error"

'*** hier habe ich Teile des Code, wo noch anderes stand, was aber nicht
fürs senden relavant ist gekürzt.



Kill strMyPDF
End If
'
End If

ExitHere:
Exit Sub


HandleErr:
Resume ExitHere
' Ende des Fehlerbehandlungsblocks.
End Sub

*************

Danke für eure Hilfe

Gruß
Michael

A2k, SP3
 

Lesen sie die antworten

#1 Henry Habermacher
08/07/2008 - 13:16 | Warnen spam
Hallo Michael

Du solltest mal die RFC821 lesen. Dort steht drin, welches Schlüsselwort für
CC und BCC zu verwenden ist. Du kannst Nicht einfach ein weiteres TO
schicken, das geht nicht. TO ist eine ; separierte Liste von UserIDs.

"Michael Alexander" wrote in message
news:
'Send Subject line
Winsock1.SendData "From:" & Me!txtSenderName & " <" &
Me!txtSender & ">" & vbCrLf
Winsock1.SendData "To:" & Me!txtRecipientName & " <" &
Me!txtRecipient & ">" & vbCrLf
'test
Winsock1.SendData "To: " & vbCrLf



Versuch statt dessen mal:
Winsock1.SendData "CC: " & vbCrLf

Gruss
Henry


Microsoft MVP Office Access
Keine E-Mails auf Postings in NGs. Danke.
Access FAQ www.donkarl.com

Ähnliche fragen