Drew Wutka
DWUTKA at marlow.com
Tue Dec 23 12:11:08 CST 2003
Whoops. Forgot. Set the RemotePort to 25. And the RemoteHost to the SMTP server. (The HELO part is just a handshake thing....) You can put it in the code instead, where you have the wsSMTP.Connect line, you can add arguments for the host and port you want to connect too. Drew -----Original Message----- From: Dan Waters [mailto:dwaters at usinternet.com] Sent: Monday, December 22, 2003 7:32 PM To: 'Access Developers discussion and problem solving' Subject: RE: [AccessD] Route email to SMTP Server from Access Drew, How do you set up the wsSMTP object. I tried creating a new form and added the Winsock control to it, then changed it's name to wsSMTP. Still no go. What's my next step? 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 _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com