Results 1 to 12 of 12

Thread: SMTP from a ActiveX DLL

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2001
    Location
    Stockholm, Sweden
    Posts
    44

    SMTP from a ActiveX DLL

    Hi
    I need to send a SMTP message from an ActiveX DLL. Is this Possible in any way?

    /John
    ********************
    VB 6
    VB 7 (.NET)
    DarkBasic (Beginner)
    ********************

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    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.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3

    use CDO

    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)
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=
    *Morgan Cellular Technologies
    [email protected]
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=

  4. #4
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    What is the exact ref? I'm running Win2K and I dont see it. I would like to expirement with it.

  5. #5
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    I thought CDO only ran on the Server versions of NT4+.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  6. #6

    Project | References...

    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.
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=
    *Morgan Cellular Technologies
    [email protected]
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=

  7. #7
    Addicted Member cyberwarpy's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    200
    Do you have any kind of online reference or protocol guide?

    SMTP is a very simple protocol.

  8. #8
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    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.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  9. #9
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    I use a freeware component called ASPEmail. It's small and easy to use. You can download it from here.

  10. #10

    Thread Starter
    Member
    Join Date
    Feb 2001
    Location
    Stockholm, Sweden
    Posts
    44
    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
    ********************
    VB 6
    VB 7 (.NET)
    DarkBasic (Beginner)
    ********************

  11. #11
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    Originally posted by cyberwarpy
    Do you have any kind of online reference or protocol guide?

    Look at the attachment. It's the official document. If you need a more comrehensive one, I can send you through email

  12. #12
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    Sorry, here it is
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width