Hi
I need to send a SMTP message from an ActiveX DLL. Is this Possible in any way?
/John
Printable View
Hi
I need to send a SMTP message from an ActiveX DLL. Is this Possible in any way?
/John
SMTP is a very simple protocol.
Why not just use winsock to connect to a mail server and send the message that way ?
If you were to use an activex control or another dll, then you would have to make sure that file (or files) is/are packaged with your app.
So winsock is the way in my opinion.
CDO handles SMTP msgs all in one handy DLL.
Why reinvent the wheel?
Put a reference on your project to CDO
Dim oCdo as new CDO.message
oCdo.to = "[email protected]"
oCdo.textbody = "Hey There"
oCdo.subject = "Blah"
oCdo.send
(this example uses the CDO for Win 2000 library but there are libraries with different syntaxes for NT and earlier)
What is the exact ref? I'm running Win2K and I dont see it. I would like to expirement with it.
I thought CDO only ran on the Server versions of NT4+.
Microsoft CDO 1.21 - "CDO.dll" is the oldest
Microsoft CDO for NTS 1.2 - "cdonts.dll" (Active Server Pages / NT 4 )
Microsoft CDO for Windows 2000 library "cdosys.dll"
I'm running win 2k Server, so if you're on a workstation you may have to install some extra things from your workstation CD or just download the DLL itself.
Do you have any kind of online reference or protocol guide?
Quote:
SMTP is a very simple protocol.
Nah I dont.
Either telnet to an smtp server and fiddle with it there, or have your mail client connect through a bouncer app (which you will have written (kinda like a proxy server)), and then record all the commands sent between.
I use a freeware component called ASPEmail. It's small and easy to use. You can download it from here.
I fixed it with the winsock control, Using the following code: Dim Progress
Dim Green_light As Boolean
Dim DATAFile As String
Private Sub cmdEnd_Click()
If Winsock1.State = sckOpen Then Winsock1.Close
End
End Sub
Private Sub Command1_Click()
Winsock1.Close
Winsock1.Connect SMTPServer , "25" 'port 25
Do While Winsock1.State <> sckConnected 'finds out if connected
DoEvents
Label1.Caption = Winsock1.State
Loop
Do While Green_light = False
DoEvents
status.Text = "Waiting for reply..."
Loop
Winsock1.SendData "MAIL FROM: " & "[email protected]" & Chr$(13) & Chr$(10) 'it then sends the data out of the text boxes
Do While Progress <> 1
DoEvents
status.Text = "Sending data. (1 of 3)"
Loop
Winsock1.SendData "RCPT TO: " & "[email protected]" & Chr$(13) & Chr$(10)
Do While Progress <> 2
DoEvents
status.Text = "Sending data. (2 of 3)"
Loop
Winsock1.SendData "DATA" & Chr$(13) & Chr$(10)
Do While Progress <> 3
DoEvents
status.Text = "Setting up body transfer..."
Loop
Winsock1.SendData "FROM: " & "[email protected]" & " <" & "OCAB FTP Server" & ">" & Chr$(13) & Chr$(10)
Winsock1.SendData "TO: " & "[email protected]" & " <" & "[email protected]" & ">" & Chr$(13) & Chr$(10)
Winsock1.SendData "SUBJECT: " & "test" & Chr$(13) & Chr$(10)
Winsock1.SendData Chr$(13) & Chr$(10)
Winsock1.SendData "testmail" & Chr$(13) & Chr$(10) & "." & Chr$(13) & Chr$(10)
Do While Progress <> 4
DoEvents
Label1.Caption = Winsock1.State
status.Text = "Sending data. (3 of 3)"
Loop
Winsock1.SendData "QUIT" & Chr$(13) & Chr$(10)
Winsock1.Close
End Sub
Private Sub Form_Load()
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData DATAFile 'this just recieves the data telling us if sucefful
Reply = Mid(DATAFile, 1, 3)
MsgBox DATAFile
If Reply = 250 Or Reply = 354 Then
Progress = Progress + 1
End If
If Reply = 220 Then
Green_light = True
End If
End Sub
Thanks for Your help.
/John
Look at the attachment. It's the official document. If you need a more comrehensive one, I can send you through emailQuote:
Originally posted by cyberwarpy
Do you have any kind of online reference or protocol guide?
Sorry, here it is