[AccessD] Route email to SMTP Server from Access

Dan Waters dwaters at usinternet.com
Mon Dec 22 21:09:12 CST 2003


Drew,

Do you have a Help file or something similar for this control?  I need to
get some detailed information before I can use this.

Thanks!
Dan

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Drew Wutka
Sent: Monday, December 22, 2003 5:19 PM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] Route email to SMTP Server from Access


Here's the gist of it.  I'm including a Connect and Disconnect procedures
(command buttons), the DataArrival event for the winsock control, and the
UseData Function (just like separating the logic out of the DataArrival
event...)

You'll need module level variables for strProcess and strEmailToSend, and
you'll also need to change the airmail.net to an SMTP server that will let
you send mail.  Also, the Me.txt stuff is just text boxes so I can change
who the email is from and who it is to.  (This current config is setup to
'restore' filtered emails.  It sends the email to the original recipient,
and sends a copy to me too, so I can make sure it didn't get 'filtered'
again.

Drew



Private Sub wsSMTP_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
wsSMTP.GetData strData
Me.txtReceived = Me.txtReceived & vbCrLf & strData
UseData strData
End Sub
Private Sub cmdConnect_Click()
strProcess = "From"
If Me.wsSMTP.State > 1 Then Me.wsSMTP.Close
Me.wsSMTP.Connect
End Sub
Private Sub cmdDisconnect_Click()
Me.wsSMTP.Close
End Sub
Function UseData(strData As String)
Select Case UCase(Left(strData, 3))
    Case "220"
        Me.wsSMTP.SendData "HELO airmail.net" & vbCrLf
    Case "250"
        Select Case strProcess
            Case "From"
                Me.wsSMTP.SendData "MAIL FROM:" & Me.txtFrom & vbCrLf
                strProcess = "To"
            Case "To"
                Me.wsSMTP.SendData "RCPT TO:" & Me.txtTo & vbCrLf
                strProcess = "ToAgain"
            Case "ToAgain"
                Me.wsSMTP.SendData "RCPT TO:" & Me.txtFrom & vbCrLf
                strProcess = "Data"
            Case "Data"
                Me.wsSMTP.SendData "DATA" & vbCrLf
                strProcess = "Done"
            Case "Done"
        End Select
    Case "345", "354"
        Me.wsSMTP.SendData strEmailToSend & vbCrLf & "." & vbCrLf 
End Select
End Function

-----Original Message-----
From: Robert Gracie [mailto:Subscriptions at servicexp.com]
Sent: Monday, December 22, 2003 4:40 PM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] Route email to SMTP Server from Access


Drew,
 If you don't mind...:-) I would like a piece of that code..

Robert Gracie
Infos at servicexp.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Drew Wutka
Sent: Monday, December 22, 2003 2:59 PM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] Route email to SMTP Server from Access


Catching up with all these posts, after a week of the flu.  Did you go with
something on this Dan?  If not, and if you want to play around with the
MSWinsock control, I can send you some code to just simply send an email
directly through SMTP.  No huss, no fuss.  (Though no formatting
either...<grin>, unless of course, you want to take a BIG crash course on
MIME formatting).

Drew
SNIP


_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list